Virtualenv-Python 3-Ubuntu 14.04 64位 [英] Virtualenv - Python 3 - Ubuntu 14.04 64 bit
问题描述
我正在尝试在Ubuntu 64位14.04上为Python 3安装virtualenv.
I am trying to install virtualenv for Python 3 on Ubuntu 64bit 14.04.
我使用以下命令为Python3安装了pip:
I have installed pip for Python3 using:
pip3 install virtualenv
,一切正常.现在,尽管我尝试使用virtualenv命令来实际创建环境,并得到未安装的错误(我想是因为我尚未为Python 2安装它,而这正是它要使用的内容)
and everything works fine. Now though I am trying to use virtualenv command to actually create the environment and getting the error that it is not install (i guess because I haven't installed it for Python 2 and that is what it is trying to use)
如何为Python 3使用virtualenv?我已经搜索了文档,但是看不到它说了什么.
How do I use the virtualenv for Python 3? I have searched the documentation but can't see where it says what to do.
推荐答案
我在OS X上的开发环境中遇到了同样的问题,我可以通过简单地调用virtualenv
和目标目录的路径来创建Python 3虚拟环境. .您应该能够通过以下两种方式之一创建Python 3.x虚拟环境:
I had the same issue coming from development environments on OS X where I could create Python 3 virtual environments by simply invoking virtualenv
and the path to the target directory. You should be able to create a Python 3.x virtual environment in one of two ways:
-
从PyPi(
$ pip3 install virtualenv
)完成安装virtualenv
,然后从命令行将其作为模块调用:
Install
virtualenv
from the PyPi as you've done ($ pip3 install virtualenv
), then by calling it as a module from the command line:
$ python3 -m virtualenv /path/to/directory
使用 venv 模块,您可以通过apt-get
. (请注意,Python 3.3是引入此模块的时间,因此此答案假定您至少正在使用该模块):
Use the venv module, which you can install through apt-get
. (Note that Python 3.3 is when this module was introduced, so this answer assumes you're working with at least that):
$ sudo apt-get install python3.4-venv
然后,您可以使用以下方式设置虚拟环境
Then you can set up your virtual environment with
$ pyvenv-3.4 /path/to/directory
并使用
$ source /path/to/directory/bin/activate
您还可以查看这篇文章,其中讨论了venv
模块和virtualenv
之间的区别.祝你好运!
You might also look at this post, which discusses differences between the venv
module and virtualenv
. Best of luck!
这篇关于Virtualenv-Python 3-Ubuntu 14.04 64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!