Python version problem when creating virtualenv
talebipour opened this issue · comments
If the host machine has both version 2 and 3 of python, virtual environment is created based on default python version, regardless of pythonBinary config of extension. This is the default behaviour of 'pythonBinary -m virtualenv' command.
Adding --python=pythonBinary to virtualenv creation command may be a simple fix for this problem.
On my ubuntu I have 'python' for python 2 and 'python3' for python 3.
python3 -m virtualenv test
creates environment with python 3.
Please describe how you reproduce your case.
This is the default behaviour of 'pythonBinary -m virtualenv' command.
According to docs (for version 20):
virtualenv being a python application has always at least one such available, the one virtualenv itself is using it, and as such this is the default discovered element. This means that if you install virtualenv under python 3.8, virtualenv will by default create virtual environments that are also of version 3.8.
If you did not install virtualenv manually the plugin will automatically install older virtualenv version (python.virtualenvVersion = '16.7.9'
). Virtualenv 20 was a major rewrite so I intentionally put older virtualenv (known to be working).
And in this case:
The default is the interpreter that virtualenv was installed with (like /usr/bin/python)
So, in theory, virtualenv should use correct python (otherwise python -m virtualenv
wouldn't work).
If you just need to get it working quicker, you can try to install the latest virtualenv manually (update automatically installed one):
python3 -m pip install -U virtualenv --user
(I assume you were using virtualenv 16, installed by plugin, and maybe 20 will behave differently)
To verify virtualenv version:
python3 -m virtualenv --version
I tested what u said with virtualenv==16.7.10 and as you said it worked. It seems that it depends on virtualenv version. So, I think we can close this issue.
Thanks for your support.