Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make venv install a python3.6 binary?

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)

like image 685
fonini Avatar asked Sep 17 '25 11:09

fonini


2 Answers

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
like image 61
SteveJ Avatar answered Sep 20 '25 00:09

SteveJ


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

like image 21
ThisGuyCantEven Avatar answered Sep 20 '25 01:09

ThisGuyCantEven