简体   繁体   English

Python venv 不在我的虚拟环境下安装包

[英]Python venv not installing packages under my virtual environment

I have created and activated a virtual environment with Python on my Linux installation (On my AWS EC2 instance).我已经在我的 Linux 安装(在我的 AWS EC2 实例上)上使用 Python 创建并激活了一个虚拟环境。 It says it's using the correct python interpreter when I run which python3 .当我运行which python3时,它说它使用了正确的 python 解释器。 But n.netheless when I run python3 -m pip install <package> it's not there when I run pip freeze.但是 n.netheless 当我运行python3 -m pip install <package>当我运行 pip freeze 时它不存在。 It keeps installing to my global installation它一直安装到我的全局安装

Python3 installation Python3安装

在此处输入图像描述

pip installation: pip安装:

在此处输入图像描述

pip freeze: pip冻结:

在此处输入图像描述

I also get this error when I try to install without the --user flag: ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/var/www/html/flask_api/flask_env/lib/python3.7/site-packages/当我尝试在没有--user标志的情况下安装时,我也会收到此错误: ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/var/www/html/flask_api/flask_env/lib/python3.7/site-packages/

Why is not actually using the interpreter and storing it where it needs to be?为什么不实际使用解释器并将其存储在需要的地方?

Why run 'which python' then run python3?为什么运行'which python'然后运行python3? ... Try 'which python3' (even better, run 'type python3' because it could be an alias that bypasses your venv) ...尝试'which python3'(更好的是,运行'type python3',因为它可能是绕过你的venv的别名)

Delete Your actual virtual environment.删除您的实际虚拟环境。 And try again by following the python doc然后按照 python 文档重试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM