Pip installs packages in pyenv root even when virtual environment is activated

Viewed 698

I try to install a package with pip in a virtual environement previously created with venv. The Python version is managed through pyenv. I don't want to use pyenv to create the virtual environment.

The project is set up this way. To the project empty directory, I added a .python-version containing the version 3.8.2. Then I created my virtual environement using python -m venv .venv. Then I activated the environement using source .venv/bin/activate. Now the command line starts with a (.env). However, when I try to install some package with pip install some-package, the package ends up in {pyen_home}/versions/3.8.2/lib/python3.8/site-packages, instead of the virtual environment.

What's irritating is that I'm almost certain that I did manage to install package in the virtual environment that way before, but not anymore, so I don't see what I'm missing.

1 Answers

Content of your .python-version should be .venv.

As far as I know you should not create this file by yourself. It generated when you run pyenv local .venv. And venv activates automatically.

Also proper way to create virtual environment is pyenv virtualenv {python-version} {venv-name}. Read the docs carefully.

Related