Home > Software engineering >  pip install in the wrong folder when virtual environment is active
pip install in the wrong folder when virtual environment is active

Time:07-18

I have more than one project that I'm working on, when I set up the second virtual environment, it installs the packages to the Python directory instead of my virtual environment. I activated the virtual environment, but it still goes to the Python directory.

PS C:\Users\mtthw\PycharmProjects\RandomPasswordGenerator> python -m virtualenv venv -p python3
created virtual environment CPython3.10.5.final.0-64 in 1438ms
 creator CPython3Windows(dest=C:\Users\mtthw\PycharmProjects\RandomPasswordGenerator\venv, clear=False, no_vcs_ignore=False, global=False)
 seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\mtthw\AppData\Local\pypa\virtualenv)
   added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
PS C:\Users\mtthw\PycharmProjects\RandomPasswordGenerator> .\venv\Scripts\activate
(venv) PS C:\Users\mtthw\PycharmProjects\RandomPasswordGenerator> python -m pip install PyQt5
Requirement already satisfied: PyQt5 in c:\users\mtthw\pyver3_10_5\lib\site-packages (5.15.7)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\users\mtthw\pyver3_10_5\lib\site-packages (from PyQt5) (12.11.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.0 in c:\users\mtthw\pyver3_10_5\lib\site-packages (from PyQt5) (5.15.2)
(venv) PS C:\Users\mtthw\PycharmProjects\RandomPasswordGenerator>

Did I miss anything while setting up the virtual environment?

I use PowerShell on Windows 10 if that helps. My Python version is 3.10.5.

CodePudding user response:

You probably didn't navigate to your project folder by providing a path to it - after you do that it is time to install virtual environment. Hope that helps.

CodePudding user response:

I found the issue.

When I first set up my virtual environment for my first project, PowerShell couldn't find Python, so I set it with the following code:

Set-Alias python "C:\Users\mtthw\pyver3_10_5\python.exe"

But I didn't know that was temporary, so when I started to make another virtual environment, it just installed everything to the path that Python is in and not the virtual environment.

I used:

$env:path='$env:Path;C:\Users\mtthw\pyver3_10_5'

And then I went on to set the virtual environment again at it worked this time. The second way is permanent from what I've researched.

  • Related