[英]Change the python2.7 package to my required python3.5 package when use virtualenv
When I create the virtualenv, if I do not add the --no-site-packages
as param: 创建virtualenv时,如果不将--no-site-packages
为参数:
virtualenv venv
I can get the packages, in the 我可以在
venv/lib/
there are a python2.7
package: 有一个python2.7
包:
python2.7
under the python2.7
there are site-packages. 在python2.7
有站点包。
But, I have a requirement, I want copy the python3.5
to the venv/lib/
how can I do this? 但是,我有一个要求,我想将python3.5
复制到venv/lib/
我该怎么做?
EDIT-1 编辑1
I use the post method create the venv
, in the venv/lib/
: 我使用post方法在venv/lib/
创建venv
:
there is the python3.5
directory, but in the venv/lib/python3.5/site-packages
there are few packages: 这里有python3.5
目录,但是在venv/lib/python3.5/site-packages
有几个软件包:
But in my Mac's sitepages: 但是在Mac的网站页面中:
there are so many packages, my requirement is add those packages in the venv
when create the venv
: 有很多软件包,我的要求是在创建venv
时将这些软件包添加到venv
:
my origin site-packages path is: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
我的原始站点软件包路径为: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
EIDT-2 EIDT-2
Before, I do not use virtualenv, I have installed many site-packages in my Mac, ( /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
), and I want to use venv
now, so I am looking for a method to create the venv
and the site-packages I have installed should include in it. 以前,我不使用virtualenv,我在Mac中安装了许多站点程序包( /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
),并且我想使用venv
现在,所以我正在寻找一种创建venv
的方法,我已安装的站点软件包应包括在其中。
First of all you should install virtualenv
using python3.5. 首先,您应该使用python3.5安装virtualenv
。
there is a tricky way that I use, I add some lines to the .bashrc
file like this: 我使用了一种棘手的方法,我向.bashrc
文件中添加了几行,如下所示:
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
alias v.activate="source /usr/local/bin/virtualenvwrapper.sh"
so whenever I want to change my virtualenv
to be on python3.5 I run the v.activate
command, and then create my virtual environment with python3.5. 因此,每当我想将virtualenv
更改为在python3.5上时,我都会运行v.activate
命令,然后使用python3.5创建我的虚拟环境。
remember this that: 记住这一点:
1.I use
virtualenvwrapper
instead ofvirtualenv
1.我使用virtualenvwrapper
而不是virtualenv
2.Dont forget to run
source .bashrc
after you add those lines tobashrc
2.在将这些行添加到bashrc
之后,不要忘记运行source .bashrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.