Pyvenv 无法创建虚拟环境 [英] Pyvenv cannot create virtual environment

查看:38
本文介绍了Pyvenv 无法创建虚拟环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我将 virtualenv 用于 python2.x.在经历了unicode编码/解码冲突后,我决定升级到3.x,但我无法使用pyvenv创建virtualenv.

Usually I use virtualenv for python2.x. After some bitter experience with unicode encoding/decoding clash, I decided to upgrade to 3.x, But I can't create a virtualenv using pyvenv.

$ pyvenv-3.4 env
Error: Command '['/home/user/delete_this/env/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

另外,如果有人指出 python3.x 的良好虚拟环境,我将不胜感激,因为我看到了很多选择.

Also I'd be grateful if someone points to a good virtual environment for python3.x since I see a lot of options.

推荐答案

这是一种与 O/S 相当的方法...

pyvenvpython 命令本身都包含一个 --without-pip 选项,使您能够解决这个问题;无需求助于 setuptool 或其他令人头疼的问题.记下我下面的内联注释,这是如何做到的,而且很容易理解:

Both the pyvenv and python commands themselves include a --without-pip option that enable you to work around this issue; without resorting to setuptool or other headaches. Taking note of my inline comments below, here's how to do it, and is very easy to understand:

user$ pyvenv --without-pip ./pyvenv.d          # Create virtual environment this way;
user$ python -m venv --without-pip ./pyvenv.d  # --OR-- this newer way. Both work.

user$ source ./pyvenv.d/bin/activate  # Now activate this new virtual environment.
(pyvenv.d) user$

# Within it, invoke this well-known script to manually install pip(1) into /pyvenv.d:
(pyvenv.d) user$ curl https://bootstrap.pypa.io/get-pip.py | python

(pyvenv.d) user$ deactivate           # Next, reactivate this virtual environment,
user$ source ./pyvenv.d/bin/activate  # which will now include the pip(1) command.
(pyvenv.d) user$

(pyvenv.d) user$ which pip            # Verify that pip(1) is indeed present.
/path/to/pyvenv.d/bin/pip

(pyvenv.d) user$ pip install --upgrade pip # And finally, upgrade pip(1) itself;
(pyvenv.d) user$                           # although it will likely be the
                                           # latest version. And that's it!

我希望这会有所帮助.\(◠﹏◠)/

I hope this helps. \(◠﹏◠)/

这篇关于Pyvenv 无法创建虚拟环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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