I've added the following lines to my bash, but mkproject
keeps creating python 2.7 folders into the virtual env, therefore I still need to use -p python3
, which I'd like to not have to do.
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
source /usr/local/bin/virtualenvwrapper_lazy.sh
virtualenvwrapper
understands the VIRTUALENVWRAPPER_VIRTUALENV
environment variable, you need to set it to the virtualenv
appropriate to the python version you're using. For example:
export VIRTUALENVWRAPPER_VIRTUALENV=virtualenv3
This is needed because virtualenvwrapper
executes virtualenv
as a shell script (without adding python2
or python3
in the front of the command).
This way the virtualenv
script is executed with the interpreter defined in its shebang (#!
).
Most Linux distros provide two packages: virtualenv2
and virtualenv3
each containing one script:
virtualenv2
:
#!/usr/bin/python2
import virtualenv
virtualenv.main()
virtualenv3
:
#!/usr/bin/python3
import virtualenv
virtualenv.main()
On a Mac you use brew
for the python
installation. Therefore there is nothing wrong with copying the virtualenv
script into two instances: vritualenv2
and virtualenv3
and change the shebang to the correct python version.
(You need to install the virtualenv
eggs, through pip
, for each python version.)
I defined an alias in the .bashrc
file to overwrite the mkproject
command to use python3 by default:
alias mkproject='mkproject --python=/usr/bin/python3'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With