在Windows而非Windows上的virtualenv的全局环境中安装软件包 [英] Pip installing packages in global environment instead of virtualenv on Windows

查看:141
本文介绍了在Windows而非Windows上的virtualenv的全局环境中安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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

我已经尝试了一次又一次,但是它总是在全局文件夹中安装任何软件包.但是,当我使用pipE:\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的全局环境中安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆