问题描述
我正在使用pycharm,为此,我正在使用python virtualenv.
I am using pycharm and for that i am using python virtualenv.
我使用penv\Scripts\activate.bat
命令激活virtualenv.但是,当我运行pip install requests
时,它将安装在全局文件夹中,而不是本地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.
where python
的输出如下:
E:\app-backend\penv\Scripts\python.exe
C:\Users\Hardik\AppData\Local\Programs\Python\Python37\python.exe
where pip
的输出如下:
E:\app-backend\penv\Scripts\pip.exe
C:\Users\Hardik\AppData\Local\Programs\Python\Python37\Scripts\pip.exe
我已经尝试了一次又一次,但是它总是在全局文件夹中安装任何软件包.但是,当我使用pip
的E:\app-backend\penv\Scripts\pip.exe
安装运行任何命令时,它将在本地virtualenv中安装该软件包.
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?
推荐答案
您应该在虚拟环境中运行python.例如:
You should run python from your virtual enviromment.For example:
E:\app-backend\penv\Scripts\python.exe -m pip list
但是您应该先激活您的venv:
But you should activate your venv first:
E:\app-backend\penv\Scripts\activate
这篇关于在Windows而非Windows上的virtualenv的全局环境中安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!