Reputation: 53
I installed brew, python3 (default and latest version) and pip3, pyenv.
TensorFlow does not support python3.7 now, so I heard that I should make a virtualenv that runs 3.6 or lower version independently.
I installed python 3.6.7 by pyenv install 3.6.7
but can't make virtualenv -p 3.6.7 (mydir)
because 3.6.7 is not in the PATH
(usr/local/bin
).
How can I update my PATH
?
Upvotes: 5
Views: 10609
Reputation: 189357
You don't need the executable to be on the PATH. Assuming you want /usr/local/bin/python3.6.7
to be used in the virtual environment,
virtualenv -p /usr/local/bin/python3.6.7 mydir
With pyenv
specifically, you could also do
/Users/you/.pyenv/versions/3.6.7/bin/python -m venv mydir
Updating your PATH
is easy:
PATH=/usr/local/bin:$PATH
This will only update it in your current session; you might want to add this to your shell's startup files to make it permanent. This is a common FAQ but depends on a number of factors (your shell, etc) so google for details. Here is one question with several popular variants in the answers: Setting PATH environment variable in OSX permanently
Upvotes: 5
Reputation: 31
I just set up a MacOS system that had python3.9 and I wanted to create a venv with 3.11, here's how I did it.
in terminal:
brew install [email protected]
python3.11 -m venv PATH_TO_YOUR_NEW_VENV
Upvotes: 3
Reputation: 2028
I know that this doesn't answer the question exactly, but for completeness I'd like to add an Anaconda solution. Provided that an Anaconda environment is present on the system, a new Python environment can be created using conda create -n py36 python=3.6 pip
. The name py36
can be arbitrarily chosen (could also be e.g. myenv
or tensorflow
), the desired Python version (in this example 3.6) is specified by python=3.6
.
This environment can then be activated using conda activate py36
(or whatever name you assigned in the previous step). Once the environment is active, you can install tensorflow
via pip
: pip install tensorflow-gpu
. To deactivate the current environment and return to the default environment, use conda deactivate
. In this way, you don't have to modify PATH
variables.
See also this documentation page for more details on the Anaconda environment.
Upvotes: 0