简体   繁体   English

python 3.8 venv 缺少激活命令

[英]python 3.8 venv missing activate command

I compiled Python 3.8.1 under a user's home directory with我在用户的主目录下编译了 Python 3.8.1

configure --prefix=/home/a_user/python3.8 --enable-shared
  1. When I tried to use venv, I get:当我尝试使用 venv 时,我得到:
python3 -m venv test_env
Error: Command '['/home/a_user/test_env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
  1. test_env is created but incomplete: test_env 已创建但不完整:
test_env/
├── bin
│   ├── python -> python3
│   └── python3 -> /home/a_user/python3.8/bin/python3
├── include
├── lib
│   └── python3.8
│       └── site-packages
├── lib64 -> lib
└── pyvenv.cfg

6 directories, 3 files
  1. ensurepip does exist:确保pip确实存在:
python3 -m ensurepip
Looking in links: /tmp/tmpeqrn78f5
Requirement already satisfied: setuptools in ./python3.8/lib/python3.8/site-packages (41.2.0)
Requirement already satisfied: pip in ./python3.8/lib/python3.8/site-packages (19.2.3)

So I am clueless as to what's missing.所以我对缺少什么一无所知。

The final solution is:最终的解决方案是:

python3 -m venv --without-pip test_env
source test_env/bin/activate
python3 -m ensurepip --upgrade
pip3 install --upgrade pip

Now the virtual env is fully set and working.现在虚拟环境已完全设置并正常工作。

Just updated to last python's version, the output says it all:刚刚更新到最后一个 python 版本,输出说明了一切:

apt-get install python3-venv

After that creating env with之后创建 env 与

python3 -m venv test_venv

works as expected, creating activate scritp.按预期工作,创建激活脚本。

Cheers干杯

To expand on Vadim's answer because I cannot comment yet.扩展 Vadim 的回答,因为我还不能发表评论。

So if your having problems check to see if your desired version of python-venv is available and install it.因此,如果您遇到问题,请检查您想要的 python-venv 版本是否可用并安装它。

Replace the 3.x with your version.将 3.x 替换为您的版本。 If there are packages available they will show up in the output.如果有可用的包,它们将显示在输出中。

sudo apt search python3.7-venv

I had installed python3.7, so I did我已经安装了python3.7,所以我做了

sudo apt install python3.7-venv

instead of代替

sudo apt install python3-venv

Just in case if you have fresh os install, install first pip by following commands以防万一,如果您有全新的操作系统安装,请通过以下命令安装第一个 pip

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

After installing you can create virtual environment & would have activate script安装后,您可以创建虚拟环境并激活脚本

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

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