I have Python 3.9.6 installed on my machine, along with 3.6.5, the two of which I use for different projects. At least that is the idea. However, when I run the command pyenv global 3.9.6, I get the response 3.9.6 not installed,
I do find python#3.9/3.9.6 in my Library folder. What's going on here, what's a good way to switch environments please?
Try to use pyenv versions in order to identify the Versions Installed.
If it is not installed you can use pyenv install.
To ask your question:
-Use pyenv install -l in order to see the curent available version that can be installed. Python 3.9.6 it is not one of them!
You did not install with pyenv Python 3.9.6, it cannot be installed with pyenv. That is the reason you cannot use it.
Related
I installed python3 using homebrew, but I stumbled upon many posts mentioning that it is better to use pyenv to manage different python versions. However, I have not found a post that answers my question:
Should I uninstall python3, install pyenv, and then reinstall python3 using pyenv? Or should I just install pyenv now, would this work?
Below is output from terminal:
System python
python --version
Python 2.7.18
which python
/usr/bin/python
Python3
python3 --version
Python 3.9.10
which python3
/opt/homebrew/bin/python3
From https://justinmayer.com/posts/homebrew-python-is-not-for-you/
Homebrew’s Python is not for you. It exists to serve Homebrew, or more accurately, Homebrew’s other formulae. The primary purpose of Homebrew’s Python formula is to enable other Python-dependent Homebrew packages to work. If installing Homebrew’s Python allows you to run the occasional Python script or access the REPL, that’s a nice side benefit, but anything beyond that — including developing software with Python — is squarely out-of-scope.
You can run brew uses --installed python to check if any installed packages depend on Homebrew Python. If no packages are listed, then you can safely uninstall via brew uninstall python and use pyenv instead.
Closely related to Can I conda install an alpha or beta version of Python? but that question is about a specific version in conda-forge. If a Python release (e.g. 3.10.0b1) is available for download via https://www.python.org/download/pre-releases/ but not in the main anaconda or any other conda channel yet, what are my best bets for using it?
Open an issue at conda-forge?
Some generic conda install script to run the python installer inside an environment?
Something else...
Particularly with alpha/beta releases of Python, I'd like the protection of a conda environment for my installation. I'm worried about using the standard Python installer now as it might not play nicely, but maybe there are some mitigation measures I can take?
pyenv is probably the best way to manage Python installations (not to be confused with Python virtual environments). It can easily install and access alpha and beta versions of Python, or whatever other previous versions have been published.
Unfortunately, pyenv does not work in Windows outside the Windows Subsystem for Linux. Fortunately, you can use pyenv-win, which is a port of pyenv for Windows, and is recommended by the authors of pyenv. To install it, follow their installation instructions.
Once you've got it installed, you can run the following to install Python 3.10.0b1:
pyenv install 3.10.0b1
pyenv global 3.10.0b1
Note that alpha/beta releases are not permanent, so when you actually run these commands 3.10.0b1 may no longer be available. You can run pyenv update to update pyenv, which will inform it of the currently available versions. pyenv install 3.10.<TAB><TAB> will show you which versions of Python 3.10 can be installed.
You can test it by running:
python -V
You should get an output of Python 3.10.0b1 if everything is in order.
To use Conda with pyenv, see this answer: https://stackoverflow.com/a/58045984/5946921
I tried downloading v2.7.x but it wasn't available. Almost all sites have updated to v3.x. If possible, please share the download link too.
I am using the Pycharm IDE and current interpreter is v3.4.
I want to shift to 2.7.1
How do I add the 2.7 interpreter.
Try the links here:
https://www.python.org/download/releases/2.7.1/
I was able to download.
you can use pyenv to mange multiple versions of python. details about how to install can be find in the link above.
after installation you can simply install python 2.7 like this.
pyenv install 2.7.8
to install python 3.4
pyenv install 3.4.0
to make global python to 2.7.8 at any time
pyenv global 2.7.8
You can download python2.7 from python.org and install it. you can then call
python2.7
on your terminal or cmd [after setting the env variable] to check if the installation was successful.
So, for some reason, I have way too many versions of python on my Mac.
Running python in the terminal gets me Python 2.7.10.
python2 gets me Python 2.7.14.
python2.7 gets me 2.7.13.
python2.6 gets me 2.6.9.
python3 gets me 3.6.3.
python3.6 gets me 3.6.3 again. Not sure if this is a separate install or not.
python3.4 gets me 3.4.7.
So I have 6, possibly 7 versions of Python. And I have no idea what to do.
As for pip, I have the following installed: pip, pip2, pip2.6, pip2.7, pip3, and pip3.6.
Some of these versions of Python were shipped with the OS, and others were installed with Homebrew.
So it's a terrifying, yet sort of hilarious mess I've gotten myself into. How can I better manage my versions? Most of the versions installed I do not use, but can't remove them because they are part of the system. So how can I make my Python versions less of a pain?
I recommend looking into pyenv, it makes managing multiple versions of Python much easier. With the virtualenv plugin life gets even better. With both installed you can do something like this:
pyenv install 2.7.13
pyenv install 3.5.1
pyenv install 3.6.3
pyenv virtualenv 2.7.13 proj1
pyenv virutalenv 3.6.3 proj2
pyenv activate proj2
python -V # 3.6.3
pyenv activate proj1
python -V # 2.7.13
And of course each project now has its own clean virtual environment you can install packages in with pip.
I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything.
Now, If I type python --version in the terminal, the correct version is started. However, pip is still "tied" to the default version of Python.
How do I go about telling OSX to look at the new version of Python for everything?
Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv.
A common pattern of Python installation on the mac is to use Home Brew which is a package manager for the mac. You can then install python using:
sudo brew update
brew install python
Provided you have the XCode command line tools already installed.
After I think that the Home Brew Python will be the first in the path. If this is not the case, it might be simpler to use a virtualenv by installing the package with the pip provided by the Mac Brew install (/usr/local/Cellar/python/2.7.5/bin/pip).
After this is done you need to create a virtualenv
virtualenv ~/path/to/the/env
and to activate it
source ~/path/to/the/env/bin/activate
This will be a brand new python and your path will be configured correctly (the python and the pip will be the right ones). You can always delete it, deactivate it or source it as needed.