venv 不创建激活脚本 python3 [英] venv doesn't create activate script python3

查看:30
本文介绍了venv 不创建激活脚本 python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试在 ubuntu 上使用 venv 和 python 3 创建 virtulenv 时,它不会创建激活脚本.它以错误 1 ​​连续退出.

When trying to create a virtulenv using venv with python 3 on ubuntu it isn’t creating an activate script. It conitunally exits with an error 1.

关注 SO 上的文档和其他帖子,例如 https://stackoverflow.com/a/19848770

Following docs and other posts on SO such as https://stackoverflow.com/a/19848770

我尝试了两种不同的方式来创建它.

I have tried creating it 2 different ways.

sayth@sayth-TravelMate-5740G:~/scripts$ python3 -m venv test4
Error: Command '['/home/sayth/scripts/test4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ source test4/bin/activate
bash: test4/bin/activate: No such file or directory
sayth@sayth-TravelMate-5740G:~/scripts$ ls test4/bin/
python  python3

sayth@sayth-TravelMate-5740G:~/scripts$ pyvenv-3.4 test5
Error: Command '['/home/sayth/scripts/test5/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ ls test5/bin/
python  python3  python3.4

我怎样才能让它完全创建一个 venv?

How can I get it to fully create a venv?

如果我按照下面的方法做仍然没有成功,不确定是什么问题?

If I do it as below with stil no success unsure what the issue is?

sayth@sayth-TravelMate-5740G:~/scripts$ python3 -Im venv panda3
Error: Command '['/home/sayth/scripts/panda3/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ python3 -m venv panda4
Error: Command '['/home/sayth/scripts/panda4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

推荐答案

看起来您正在使用 Ubuntu 14.04.它附带了一个损坏 pyvenv.使用 Python 3

Looks like you are using Ubuntu 14.04. It was shipped with a broken pyvenv. There is a simple work around to create venv using Python 3

1.创建没有 pip 的 venv

python3 -m venv --without-pip test4

pyvenv-3.4 --without-pip test4

2.在你的环境中获取 pip

source test4/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source test4/bin/activate

pyvenv-3.4 --without-pip myvenv
source ./myvenv/bin/activate
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.4.4.tar.gz
tar -vzxf setuptools-3.4.4.tar.gz
cd setuptools-3.4.4
python setup.py install
cd ..
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
tar -vzxf pip-1.5.6.tar.gz
cd pip-1.5.6
python setup.py install
cd ..
deactivate
source ./myvenv/bin/activate

来源:HackerNewsAskUbuntu

这篇关于venv 不创建激活脚本 python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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