Source: Baidu SEO company I have a Debian systems currently use python 2.5.4 running. I installed correctly virtualenv, everything is normal. Can I virtualenv used with other versions of Python?
I compiled Python 2.6.2, and want to use it with some of the virtualenv. Overwrite binaries enough? Or do I have to change something about the library?
#1st Floor
These are your needs and then execute your version of Python from the source code to create venv from compilation and installation of Python on a shared hosting environment steps. For Python 2.7.9, you can operate in the following manner:
mkdir ~/src
wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -zxvf Python-2.7.9.tgz cd Python-2.7.9 mkdir ~/.localpython ./configure --prefix=$HOME/.localpython make make install
Virtual Environment
cd ~/src
wget https://pypi.python.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz#md5=0ed59863994daf1292827ffdbba80a63
tar -zxvf virtualenv-15.0.2.tar.gz cd virtualenv-15.0.2/ ~/.localpython/bin/python setup.py install virtualenv ve -p $HOME/.localpython/bin/python2.7 source ve/bin/activate
Naturally, this can be applied to any situation that you want to copy the exact environmental work and deployment.
#2nd Floor
When you create virtualenv instance, just use --python
(or Short -p
) option to specify the Python executable file to use, for example:
virtualenv --python=/usr/bin/python2.6 <path/to/new/virtualenv/>
Note: For Python 3.3 or later, please see the following Aelfinn answer.
#3rd floor
virtualenv --python=/usr/bin/python2.6 <path/to/myvirtualenv>
#4th floor
Let's say you currently installed python 2.7 in virtualenv in. But you want to use python3.2
, you must use the following python3.2
update:
$ virtualenv --python=/usr/bin/python3.2 name_of_your_virtualenv
Then activate your way through the following virtualenv :
$ source activate name_of_your_virtualenv
Then do the following: Use the shell python --version
to check if your version has been updated.
#5th Floor
Mac OSX 10.6.8(Snow Leopard):
1) When you pip install virtualenv
, pip command with your version associated with a python, and virtualenv
is mounted to the python version. you can do
$ which pip
To see what version of python. If you see something like the following:
$ which pip
/usr/local/bin/pip
Then do:
$ ls -al /usr/local/bin/pip
lrwxrwxr-x 1 root admin 65 Apr 10 2015 /usr/local/bin/pip -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pip
You can see the python version in the output.
By default, it will be for python versions of any new environment that you create. However, you can use -p flag
any version of python installed on the specified computer to use in the new environment:
$ virtualenv -p python3.2 my_env
Running virtualenv with interpreter /usr/local/bin/python3.2
New python executable in my_env/bin/python Installing setuptools, pip...done.
virtualenv my_env
Will be created in the current directory in a folder, which contains Python executable file and a copy of the pip [command] can be used to install additional software packages.
http://docs.python-guide.org/en/latest/dev/virtualenvs/
virtualenv
Just copy the python from a location on your computer to the newly created my_env / bin / directory.
2) The system is located in python /usr/bin
, but I installed various versions of python are installed in the default case:
/usr/local/bin
3) I installed a variety of python3.2
names like python2.7
or python3.2
I can use these names instead of the full path.
======== ========= virtual environment
1) I work in the virtualenvwrapper encounter some problems. This is what I finally put ~/.bash_profile
:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/django_projects #Not very important -- mkproject command uses this #Added the following based on: #http://stackoverflow.com/questions/19665327/virtualenvwrapper-installation-snow-leopard-python export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7 #source /usr/local/bin/virtualenvwrapper.sh source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh
2) -p option
the work virtualenvwrapper different: I must specify the full path to the python interpreter to be used in the new environment (when I do not want to use the default python version):
$ mkvirtualenv -p /usr/local/bin/python3.2 my_env
Running virtualenv with interpreter /usr/local/bin/python3
New python executable in my_env/bin/python Installing setuptools, pip...done. Usage: source deactivate removes the 'bin' directory of the environment activated with 'source activate' from PATH.
And virtualenv different, virtualenvwrapper environment will be created in the $ WORKON_HOME environment variables specified location. This all in one place in your environment.