2

In my ~ directory, typing "python" will start, well, python.

However, in my /usr/python/cgi-bin directory, typing python gets me an error message

 pyenv: python3: command not found
 The `python3' command exists in these Python versions:
 3.4.1

Well, that's good but extremely useless.

If, in the /usr/python/cgi-bin directory, I type

pyenv local

I get the really useless

pyenv: no local version configured for this directory

Whoever writes this stuff, you should totally put what to do or where to look when you start popping out error messages

How do I setup pyenv so that the pyenv in my ~ directory and the pyenv in some other directory - for the sake of argument let's use the /usr/python/cgi-bin directory - both do the same thing?

bharal
  • 133
  • 1
  • 7

1 Answers1

3

You should only have a single pyenv in your path. Generally, this is in the user's home directory (e.g. /home/dave/.pyenv ), but that is simply convention. You don't want to have two pyenvs installed because only one is going to be used and there is really no reason to. You want to have a single pyenv and use it to manage the python that is used globally and/or locally (as in specific to individual directories). So, you can use the command

pyenv global 2.7.8

to have python 2.7.8 used unless you are in a directory with a .python-version file (or one of its subdirectories) or you have set the PYENV_VERSION environment variable.

By the way, rather than creating a .python-version file, use the command

pyenv local 3.4.1

or whatever version of python you desire. Similarly, you can use

pyenv shell 3.4.1

to have pyenv set the PYENV_VERSION environment variable. The priority for which python version will be used is PYENV_VERSION > .python-version file > global setting or shell > local > global.

Hope this helps.