1

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 e.g. 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?

user2887278
  • 165
  • 2
  • 13

1 Answers1

3

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.

user2887278
  • 165
  • 2
  • 13