When I run python -m venv
, the virtual environment directory that venv
creates includes a binary named python
and another named python3
which is just a link to python
. (In my installation, python
is Python 3.6 and python2
is Python 2.7.)
My problem is, sometimes (and I can't understand what's the difference between subsequent invocations) it also creates another symlink python3.6
pointing to python
, but sometimes it doesn't. I need this symlink (actually, tox
needs it). The binaries pip3.6
and easy_install-3.6
are always installed in the virtualenv.
Is there any way I can make sure that python -m venv
creates a symlink python3.6
?
(Disclaimer: I'm using pyenv to manage my Python installation, but I can reproduce the behavior above using /usr/bin/python -m venv
)
When creating venvs ( python -m venv
, not virtualenv), I've had success by including the version number in the call to create;
python3.6 -m venv myvenv
You need to have the binary already available to get venv to use it, but if you have it, it shouldn't matter if you use python2 -m venv
or python3 -m venv
. If you want 3.6, try:
python -m venv python=`which python3.6` ~/envs/py36
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.