The environment is ubuntu and python 2.7 is installed.I want to use virtualenv, so
$virtualenv--python=/usr/lib/python 2.7.
I entered , but it says there is no such file.
When I looked at the python path, it appeared as follows:
[', '/usr/lib/python 2.7', '/usr/lib/python 2.7/plat-x86_64-linux-gnu', '/usr/lib/python 2.7/lib-tk', '/usr/lib/python 2.7/lib-old', '/usr/lib-old', '/lib/lib/python 2.7/lib/lib-lively-doubry-doubry-doubry-doubry-doubry-doubry-doubry-doubry-doubry-doubry-doub
I think the pass is correct, but why can't I?
python linux ubuntu
If you use sys.path
to find the path of Python, you will see the path to find the module instead of the path of Python interpreter.
To find out the full path of Python interpreters, use which
at the terminal.
which python 2
For python programs, use sys.executable
.
import sys
sys.executable
virtualenv
uses the --python
option to specify the interpreter for Python, but it is possible to specify an absolute path, but if you do not necessarily need an absolute path and want to install python 2.7, you can enter:
virtualenv -- python=python2env
Also, if you have virtualenv
installed in python 2.7 (venv
is available for Python 3, you can skip the option and enter the following:
virtualenvenv
The official virtualenv
documentation describes:
-pPYTHON_EXE, --python=PYTHON_EXE
The Python interpreter to use, e.g., – python= python 2.5 will use the python 2.5 interpreter to create the new environment. The default is the interpreter that virtualenv was installed with (like/usr/bin/python)
© 2024 OneMinuteCode. All rights reserved.