1

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?

caffreyd
  • 1,151
  • 1
  • 17
  • 25
이태한
  • 13
  • 1
  • 3
  • Do you mean `usr/local/bin` in some local directory (your home directory, perhaps?) or the absolute directory `/usr/local/bin`? – tripleee Jan 02 '19 at 09:33

2 Answers2

3

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

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

tripleee
  • 175,061
  • 34
  • 275
  • 318
0

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.

MPA
  • 1,878
  • 2
  • 26
  • 51