You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Python: How to install pygments using pip?

I had pygments (a colorizing Python code parser) running on my previous OS High Sierra. Now in Catalina it won't install.


pip install Pygments


The error I get, after a long list of other errors, is:


pkg_resources.DistributionNotFound: The 'pip==20.1.1' distribution was not found and is required by the application


How to get the pip installer working? Can someone tell me exactly how to fix the messy Python system on Catalina? I can't figure it out and it seems botched in multiple locations.

MacBook Pro 15″, macOS 10.15

Posted on Jul 13, 2020 10:27 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 14, 2020 7:46 AM

Apple supplied Python 2.7.16 and Python3 (if Xcode 11.n or command-line tools for Xcode 11 are installed), do not include pip/pip3. You should always consider the Python distributions provided by Apple as both out of date, and off limits for any third-party package installation, in case the addition train wrecks these installations.


I only install a 64-bit Python distribution from Python.org where the package installer will write the Python.framework bundle into /Library/Frameworks. This does not step on any Apple Python distribution. Additionally, the installer will create symlinks from this Python framework binaries back into /usr/local/bin; prepend a path to the Frameworks lib folder to your existing PATH, and write a Python folder into /Applications.


Although the preceding library PATH setting is automatically done for you in the Bash ~/.bash_profile dot file, it is not provided in the ~/.zshrc or ~/.zshrc_profile, so you will have to update them manually. In either case, you will want to invoke these PATH additions with:


source ~/.bash_profile
source ~/.zsh_profile


You will need a /usr/local/bin destination before the installation, and ensure that your PATH is adjusted to have /usr/local/bin occur before /usr/bin, so that you are not running the Apple installed Python 2 or Python3 binaries.


The pip installer, is not part of the now, end-of-life Python.org 2.7.18 distribution, but is bundled as pip3 in Python 3.8.4. In either case, make sure that pip/pip3 is upgraded to the latest version:


To get pip installed and updated in Python 2.7.18, use the following:


python -m ensurepip --upgrade


To upgrade the existing pip3 in the Python 3.8.4 or earlier Python3.x:


pip3 install -U pip


and for Pygments, you probably want the following (or pip3 if in Python 3.8.4):


pip install -U pygments

pip3 install -U pygments


Similar questions

1 reply
Question marked as Top-ranking reply

Jul 14, 2020 7:46 AM in response to Gnarlodious

Apple supplied Python 2.7.16 and Python3 (if Xcode 11.n or command-line tools for Xcode 11 are installed), do not include pip/pip3. You should always consider the Python distributions provided by Apple as both out of date, and off limits for any third-party package installation, in case the addition train wrecks these installations.


I only install a 64-bit Python distribution from Python.org where the package installer will write the Python.framework bundle into /Library/Frameworks. This does not step on any Apple Python distribution. Additionally, the installer will create symlinks from this Python framework binaries back into /usr/local/bin; prepend a path to the Frameworks lib folder to your existing PATH, and write a Python folder into /Applications.


Although the preceding library PATH setting is automatically done for you in the Bash ~/.bash_profile dot file, it is not provided in the ~/.zshrc or ~/.zshrc_profile, so you will have to update them manually. In either case, you will want to invoke these PATH additions with:


source ~/.bash_profile
source ~/.zsh_profile


You will need a /usr/local/bin destination before the installation, and ensure that your PATH is adjusted to have /usr/local/bin occur before /usr/bin, so that you are not running the Apple installed Python 2 or Python3 binaries.


The pip installer, is not part of the now, end-of-life Python.org 2.7.18 distribution, but is bundled as pip3 in Python 3.8.4. In either case, make sure that pip/pip3 is upgraded to the latest version:


To get pip installed and updated in Python 2.7.18, use the following:


python -m ensurepip --upgrade


To upgrade the existing pip3 in the Python 3.8.4 or earlier Python3.x:


pip3 install -U pip


and for Pygments, you probably want the following (or pip3 if in Python 3.8.4):


pip install -U pygments

pip3 install -U pygments


Python: How to install pygments using pip?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.