Install packages for python 3.x using pip - macos

My OS is Mac where the inbuilt python is 2.7 but I only want to use python 3.x.
Now I want to install some packages using pip for 3.x version, but the function pip is not defined in shell.
So how should I proceed?

Starting with 3.4.0, the PSF Mac OS X installer installs pip by default. If you do not have 3.4 already, I recommend that you install 3.4.2rc1 now or wait a few days or a week for the final 3.4.2 download. And do check the mac and tkinter info link on that page.

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

Trying to install pygame on OSX 10.11 for python2

I'm running OSX 10.11 and have python 2.7.10 installed on my computer. I want to install pygame1.9.2 for the said environment (don't want to install it for python3 which is installed on my computer as well).
When I try to install this one - http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip - it says, "This package is incompatible with this version of OS X and may fail to install." Even if I continue, installation fails somehow.
I tried "pip install pygame" then it says
"Collecting pygame Could not find a version that satisfies the
requirement pygame (from versions: ) No matching distribution found
for pygame. "
How do I install it?
(for future reference) After spending many hours I found the following command to be working!
sudo pip install --user git+https://github.com/pygame/pygame/
It's not 1.9.2 but can run what I wanted with python 2.7.10
>>> pygame.__version__
'2.0.0.dev0'

Can't figure out how to upgrade my python version from 3.4 to 3.7 in my virtual environment

In my virtual environment I am running on python 3.4.3 but need to upgrade to python 3.7 .
Show version and brew install
I have tried brew install python3 and changing the link and homebrew tells me python 3.7 is installed. When I do python --version it states python 3.4.3.
i think the best method is to leave Python 3.4.3 as is and install python 3.7. Then after installing 3.7 create a new virtual environment for python 3.7. To run 3.7 you just activate that environment.

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