How to revert to Python3.8 on my Mac using Homebrew? - macos

please see this question: How to default Python3.8 on my Mac using Homebrew?
I'm trying to accomplish the same thing. I brew installed python and that gave me the latest 3.9; however, I would like to use 3.8 to maintain dependencies.
When i check terminal for the version of python the result is always the macOS default of 2.7.
I've used this method above and many other methods, but I am new to homebrew and zsh and I have not found a work around.

I would encourage you to use pyenv to manage different python versions in your local.
brew install pyenv
pyenv install 3.7.9
pyenv install 3.8.6
Then you can control machine default by using pyenv global x.x.x
pyenv global 3.8.6

Related

How to install Python 3.10 on the base enviornment of Anaconda?

I have python 3.9 installed in the anaconda base environment and have trouble installing the latest 3.10 version. I have tried to use "conda install -c conda-forge python=3.10" but it does not help resolve my problem. Over half a day, I have iteratively applied the command in the terminal but the package would not be installed. Any suggestion?
I've tried to use "conda install -c conda-forge python=3.10" and it did not work. My software still is Python 3.9 and I cannot apply the latest python version there.
Anaconda currently doesn't support versions higher than 3.9.
You can create your own environment using your IDE that utilize Python 3.11 and install all the required libraries via pip install from the command line interface.

How can I run Python 3.9.1 natively on M1 Mac?

Seems to be impossible currently with Anaconda as well as with Xcode 12. Via idle, it runs via Rosetta. There seems to be no discussion of this so either I'm quite naive or maybe this will be useful to others as well.
Python says: "As of 3.9.1, Python now fully supports building and running on macOS 11.0 (Big Sur) and on Apple Silicon Macs (based on the ARM64 architecture). A new universal build variant, universal2, is now available to natively support both ARM64 and Intel 64 in one set of executables" https://docs.python.org/3/whatsnew/3.9.html
Please help a newbie figure out how to take advantage of his recent impulse-buy.
You can now install python 3.9.1 through multiple pathways now but the most comprehensive build environment for the full data-science suite for python at the moment (Feb 2021) on M1 ARM architecture is via miniforge.
e.g.
brew install --cask miniforge
conda init zsh
conda activate
conda install numpy scipy scikit-learn
You can now install Python 3.9.4 natively on Mac M1 (Apple Silicon). I'm using pyenv to install Python 3.7, 3.8 and 3.9 all native ARM. For example, to install 3.9.4:
$ pyenv install 3.9.4
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.4.tar.xz...
-> https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.4 to /Users/squademy/.pyenv/versions/3.9.4
For a complete guide on install pyenv and multiple Python version, you might read this article: https://squademy.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9.
I am using python3.9.4. I installed it using homebrew only.
brew install python#3.9
Also you may want to do the following to unlink and check the version number
brew unlink python3
brew link python3.9
python3 --version
I upgraded to 3.9.4
Download the Python universal installer -
https://www.python.org/downloads/mac-osx/
Note: I still could not get sudo pip install mysqlclient to install.
I had add to
update homebrew - See https://brew.sh
Add /opt/homebrew/bin to PATH in .bash_profile (don't forget to source .bash_profile)
or
Add /opt/homebrew/bin to PATH in .zprofile (don't forget to source .zprofile) if using zsh

Install specific version of python2 with homebrew

I've installed python 2.7.13 with homebrew but I need 2.7.10. It seems something trivial... I've seen similar questions like this or this but I haven't been able to install it.
I've tried to tap homebrew/versions and then do brew search python but there are no versions (rather than python2 and python3).
Homebrew doesn't do this, I would recommend using homebrew to install pyenv and then using pyenv to install and use python 2.7.10, and any other versions you need.
Get pyenv:
brew update
brew install pyenv
Then add eval "$(pyenv init -)" to your .bash_profile and relaunch terminal.
Install python 2.7.10:
pyenv install 2.7.10
You can then set 2.7.10 as the global python by using pyenv global 2.7.10 but I would instead recommend you look at the pyenv virtualenv or pyenv virtualenvwrapper projects and use a python virtual environment for your code, or set the python for your project folder only by cd'ing to your project folder and using pyenv local 2.7.10.

Update Software Version in Anaconda

I have installed python and many other useful tools on my Ubuntu 14.04 using Anaconda. I installed pysam (htslib interface for python) using
conda install pysam
However this installs the old version (0.6). The current version is 0.8.4. How can I install that version using conda. I don't want to use pip install pysam because I read somewhere it might cause problems.
Thanks.
Anaconda only provides version 0.6. You can install from binstar with:
conda install -c https://conda.anaconda.org/uhlitz pysam
This should give you version 0.8.3 for linux64. Other channels are also available.

I don't know how to update my Python version to 3.4?

I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7.
How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.
When you install Python3, you can use python3 to run python programs(or use a shebang). Python 3 also install pip. If you find your Python3 installed version of pip try to alias the pip command to the newer pip. Check this out for more info:
How to install pip for Python 3 on Mac OS X?
Try python3 or python3.4. It should print out the right version if correctly installed.
Python 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed.
I have found that making the 'python' alias replace the default version of python that the system comes with is a bad idea.
When you install a new version of python (3.4 for instance),
these two new commands are installed, specifically for the version you installed:
pip3.4
python3.4
If you're using an IDE that wants you to indicate which python version you are using the IDE will let you navigate to it in the Library folder
pip will still be for python2.7 after you download some other python version, as I think that's the current version osx comes installed with

Resources