Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run single command in specific python version with pyenv

Tags:

pyenv

I'm using notebooks mostly, so on the commandline I often only want to install a specific package for a specific python version I have. Currently, I usually change the global python version, run pip and change the global version back. Is there a way to execute a single command in a specific pyenv version?

like image 467
fbence Avatar asked Oct 17 '18 09:10

fbence


People also ask

How do I use a specific version of Python?

As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed. You can also use commands like py -3.7 to select a particular version, or py --list to see which versions can be used.

How do shims work Pyenv?

Shims are lightweight executables that simply pass your command along to pyenv. So with pyenv installed, when you run, say, pip , your operating system will do the following: Search your PATH for an executable file named pip. Find the pyenv shim named pip at the beginning of your PATH.


1 Answers

You can override which version/environment is being used via the PYENV_VERSION environment variable

# PYENV_VERSION=2.7.15 pip install package
# PYENV_VERSION=3.6.6/some_virtualenv ipython
like image 176
nicotine Avatar answered Oct 04 '22 15:10

nicotine