M
M
Maxim Zubenko2021-11-29 14:31:40
Python
Maxim Zubenko, 2021-11-29 14:31:40

Where in Linux do I need to configure the Python virtual environment to work correctly?

The point is. Earlier (about 3 years ago) I started developing at home on a VmWare virtual machine.
Compiled image:
Ubuntu 18 LTS. Python 3.6. PostgreSQL. GIT. Celery and others.
installed venv and led the development of Django 2.2.3
Made a project. Launched the client on the VPS to work. Got money.
Over time, life has changed. Programming has become far from the main occupation. Work was not at home. But after some time, the client turned to me for the modernization of the project. I opened the virtual machine. It started up fine, only Ubuntu asked for some updates. At a new job, I decided to deploy a similar configuration to work at home and work on a project at the same time.
So I took the project folder and the virtual environment folder. Packed via tar (so that the rights to the files are also preserved)
At work, I installed VmWare Player and created a virtual machine with Ubuntu 18 (the computer at work behaved extremely strangely with Ubuntu 20, so I installed the 18th one and did not bathe).
Unpacked the files. Installed PyCharm and indicated where the project is and where venv is. Ran it and it worked the first time. I started working on a project at work and at home at the same time. Through GIT, everything was easily synchronized.
Made some visuals, updated some functionality. Fixed some crutches.
But suddenly I needed new extensions for Python.

I started the terminal and found this situation. That despite the fact that after activating the venv prompt, it shows that I am allegedly in it. In fact, the pip3 freeze command shows me the global python modules, not my virtual environment. I first discovered this behavior in PyCharm. I thought, I'll go through the terminal and do everything manually. But it turned out that the same is true in the terminal. Despite the prompt (venv_ws) being shown, pip3 freeze shows the global python modules.

The strangeness (for me, and most likely out of ignorance) is that when I run a Django project through PyCharm (I click on the "green triangle" button, so to speak, or run it through debug), the project works fine. Through any browser I interact with the project. Those. By some miracle, PyCharm launches the correct virtual environment, but at the same time in the terminal (at least through the same built-in PyCharm, even through the main Ubuntu), despite the invitation, I cannot reach the reality of the virtual environment. pip3 freeze doesn't even show that Django is installed there.
And accordingly, when installing any additional. packages via pip3, they are installed in the global python, but do not get into the virtual environment of the project.

Если вы дочитали до сюда, то вы уже мои герои, ибо я понимаю, что буков действительно много, но вот именно здесь вопрос:

Что мне исправить (я думаю что в конфиге видимо виртуального окружения), чтобы оно начало работать правильно?

Подскажите в каких файлах и что именно.

С уважением.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Сергей Горностаев, 2021-11-29
@JawsIk

Виртуальные окружения не переносимы, нужно было создать новое, а не копировать.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question