I would like to specify the python version of the virtualenv. I have installed python 2.7
and 3.8
through home brew and I can create virtual environments like it is described here like so for both versions:
virtualenv --python=/usr/bin/python2.7 my-env
To now use other python versions eg 3.7
many pages recommend pyenv
. I can install a specific python version using pyenv
however when I want to use it in a similar fashion:
virtualenv --python=/Users/user/.pyenv/versions/3.7.7 my-env
I get RuntimeError: failed to query /Users/user/.pyenv/versions/3.7.7 with code 13 err: 'Permission denied'
I also tried to activate the pyenv
environment globally and use that to install. I can successfully change my python version in the terminal using pyenv
. However after creating the virtual environment it always uses the true python installed and not the one from pyenv
.
Why do I get a permission denied for something that is installed in my home folder? I never used sudo to install any of these things explicitly. How can I solve this?
Ok I now found it out. It must link to the python binary like so:
virtualenv --python=/Users/user/.pyenv/versions/3.7.7/bin/python ~/.virtualenvs/my-project
The reason why it worked with the brew installed versions was that /usr/bin/python2.7
is actually a symlinks not a folder.
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.