问题
I am using pycharm and for that i am using python virtualenv.
I activate virtualenv using penv\Scripts\activate.bat command. But when i run pip install requests, it is getting installed in global folder instead of local virtualenv folder. I am not able to understand why is the case so.
Output of where python is as follow:
E:\app-backend\penv\Scripts\python.exe
C:\Users\Hardik\AppData\Local\Programs\Python\Python37\python.exe
Output of where pip is as follow:
E:\app-backend\penv\Scripts\pip.exe
C:\Users\Hardik\AppData\Local\Programs\Python\Python37\Scripts\pip.exe
I have tried it again and again but it always installs any package in global folder. But when I run any command using E:\app-backend\penv\Scripts\pip.exe install of pip, it installs that package in local virtualenv.
Can anyone tell me what is the case happening here?
回答1:
You should run python from your virtual enviromment. For example:
E:\app-backend\penv\Scripts\python.exe -m pip list
But you should activate your venv first:
E:\app-backend\penv\Scripts\activate
来源:https://stackoverflow.com/questions/56708993/pip-installing-packages-in-global-environment-instead-of-virtualenv-on-windows