unable to install matplotlib with python3 on m1 mac using pip3 - python-3.x

I'm unable to install matplotlib through pip on my M1 Mac. I have Python 3.9.1 installed through Homebrew. I've tried the solution here: Pip install matplotlib fails on M1 Mac but it does not work for me.
I get this long error:
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): no suitable image found. Did find:
/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so: mach-o, but wrong architecture
/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so: mach-o, but wrong architecture
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 256, in <module>
setup( # Finally, pass this all along to distutils to do the heavy lifting.
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 299, in run
self.find_sources()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 306, in find_sources
mm.run()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 541, in run
self.add_defaults()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 577, in add_defaults
sdist.add_defaults(self)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/sdist.py", line 228, in add_defaults
self._add_defaults_ext()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/sdist.py", line 311, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 88, in finalize_options
self.distribution.ext_modules[:] = [
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 91, in <listcomp>
for ext in package.get_extensions()
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setupext.py", line 345, in get_extensions
add_numpy_flags(ext)
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setupext.py", line 468, in add_numpy_flags
import numpy as np
File "/opt/homebrew/lib/python3.9/site-packages/numpy/__init__.py", line 145, in <module>
from . import core
File "/opt/homebrew/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
I am able to import matplotlib with python 2.7 on my Rosetta Terminal but I am trying to use matplotlib with python3 instead.
Any help would be appreciated!

November 2021 Update
Just run the following command:
$ pip3 install matplotlib
Worked on Mac mini (M1, 2020), Monterey 12.0.1. Python 3.9.7
Feb 2021 Answer Below
In order to install matplotlib with pip3 on an M1 mac, you first need to install the dependencies Cython, numpy and Pillow from source. The following method worked for me.
Install Cython
pip3 install Cython
Install numpy
$ git clone https://github.com/numpy/numpy.git
$ cd numpy
$ pip3 install . --no-binary :all: --no-use-pep517
Install Pillow
libjpeg is necessary for Pillow so you might want to install it via brew.
$ brew install libjpeg
$ git clone https://github.com/python-pillow/Pillow.git
$ cd Pillow
$ pip3 install . --no-binary :all: --no-use-pep517
Install matplotlib
$ git clone https://github.com/matplotlib/matplotlib.git
Then you need to manually download qhull and extract the archive. (http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz on Qhull Downloads)
You will get a folder named qhull-2020.2. You then have to place the folder at matplotlib/build. The build folder may not exist so you might have to create it.
Lastly, the following command will install the matplotlib on your M1 mac.
$ cd matplotlib
$ pip3 install . --no-binary :all:
Tested for Python 3.9.1 on non-Rosetta terminal on M1 Mac mini (Big Sur 11.2.1).

I solved this by just uninstalling homebrew first and downloaded matplotlib with python3. After that i reinstalled homebrew using non-rosetta terminal. Idk how it works cause im very new to these stuff but what works works i guess.

I solved this by realizing that I had two seperate Python instances installed. When you run which python3 you get the path of your Python installation. Check to see if the path corresponds to the Python version you installed.
I fixed it by uninstalling the version of Python3 I had installed with homebrew with brew uninstall python3.
When I did which python3 again it showed a different Python installation path. I then did pip3 install Matplotlib and I was able to import Matplotlib.

1. Uninstall Following Package
pip uninstall pillow
pip uninstall numpy
pip uninstall wordcloud
pip uninstall matplotlib
pip uninstall pyparsing
pip uninstall kiwisolver
pip uninstall python-dateutil
pip uninstall cycler
pip uninstall packaging
pip uninstall fonttools
pip uninstall contourpy
pip uninstall six
2. Install matplotlib
pip install matplotlib

I originally installed python 3.9 using homebrew, but my matplotlib problem was fixed by uninstalling python and reinstalling using the download from the python website(because of architecture problems).

I found another nice way with pyenv,miniforge and conda.
pyenv install miniforge3-4.10
conda create -n env_new python=3.9
conda activate env_new
conda install poetry
peotry new project
poetry add matplotlib
Maybe it is not perfect, but it works for a variety of moduls and you can even choose python=3.8 and other python versions and everything is running on the M1.

Related

pkg_resources.DistributionNotFound: The 'platformdirs<3,>=2' distribution was not found and is required by virtualenv

I am trying to create an isolated environment using pip, the instructions from "Hands on Machine Learning With Ski-Kit and Tensor Flow" have me run these lines of code and this is the output I get. I've tried uninstalling pipenv and that creates another error where pipenv command not found. Not sure how to work around this, can anyone help? I'm using a Mac with python3.9
Darrens-MacBook-Air:~ odonned4$ cd $ML_PATH
Darrens-MacBook-Air:~ odonned4$ virtualenv env
File "/usr/local/bin/virtualenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'platformdirs<3,>=2' distribution was not found and is required by virtualenv```
What is the problem?
You are trying to run Python 3.9, right? Well, according to your error message, it seems like you're invoking Python 2.7:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
^^^
This confusion happens because macOS added Python 2.7 to the distribution for... compatibility reasons. And, probably, you have virtualenv on that distribution, but you don't have platformdirs, so creating a virtualenv fails.
How to solve the problem?
There are many ways to clarify this confusion. A good way is using python3 -m virtualenv (instead of virtualenv). That should create a virtualenv with Python 3.
Also, you can get sure that the virtualenv package is available in your Python 3.9 installation. To identify that, see if virtualenv appears when typing python3 -m pip list. If not, run python3 -m pip install virtualenv.
The real problem here is that Mac is hard wired to use python2. When using virtualenv, you might have run the command:
$ /usr/bin/easy_install virtualenv
which should have added virtualenv to the /usr/bin/ for direct use, but to be used with the default python2 instead of python3.9 which you might have installed on your own.
A simple way around is to use
$ python3 -m virtualenv <env-name>
instead of
$ virtualenv <env-name>
Or in my case, add an alias in .bash_profile:
$ alias virtualenv="python3 -m virtualenv"
which is a duct tape solution but it works as well.
Try uninstalling setuptools with
pip uninstall -y setuptools
and reinstalling it with
pip install setuptools
OR
Upgrade setuptools with
pip install --upgrade setuptools
OR
For me i have faced this issue some before in python 3.8.
I fixed it by
sudo apt install --reinstall python3-pkg-resources python3-setuptools
OR
Uninstall virtualenv and setuptools first and find pip cache folder.
pip cache dir
Delete the cache and install virtualenv and setuptools.
I JUST SAID SOME STEPS .. TRY THIS . MAY HELP : )

Spyder won't start in cmd

When I try to run spyder (any version of spyder) in cmd I get the error below.
Traceback (most recent call last):
File "C:\Users\bjwil\Anaconda3\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\bjwil\Anaconda3\Lib\site-packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "C:\Users\bjwil\Anaconda3\Lib\site-packages\spyder\app\mainwindow.py", line 87, in <module>
from qtpy import QtSvg # analysis:ignore
File "C:\Users\bjwil\Anaconda3\Lib\site-packages\qtpy\QtSvg.py", line 14, in <module>
from PyQt5.QtSvg import *
ImportError: DLL load failed: The specified procedure could not be found.
I do not get this error when run spyder in MinGW Git for Windows. I have looked for a few hours but cannot seem to find answer to why. I have the python3.dll and python36.dll extension from Anaconda3 in the Anaconda3 folder. I also cannot uninstall PyQt5 (getting PackagesNotFoundError: The following packages are missing from the target environment:
- pyqt5) and reinstall using either conda install -c dsdale24 pyqt5 or conda install --channel https://conda.anaconda.org/bpentz pyqt5. I get:
Collecting package metadata: done
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- conda[version='>=4.6.7']
- pyqt5
Use "conda search <package> --info" to see the dependencies for each package.
conda update --all fixed the same issue for me.
There may different reason for this problem. Sometimes it is because you forget to install spyder in the anaconda environment.
You can install Spyder from anaconda prompt by running
conda install spyder
Also, you can install spyder by going to the anaconda navigator.

pip3 install not working - No module named 'pip._vendor.pkg_resources'

When trying to install a package for Python 3 (in Ubuntu), using pip3 install packageName (or sudo pip3 install packageName), I get the following error message:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
I have been reading for days and have tried the following WITHOUT any success:
Un-installing and re-installing pip3 using the following code: sudo apt-get remove python3-pip followed by sudo apt-get install python3-pip. This was suggested in several posts that say that sometimes pip3 doesn't install properly for Ubuntu. However, it didn't work.
Other post suggested it was an ssl package problem and that if the ssl package doesn't load on Python3, that's the issue. However the following command does not raise any error: python3 -c "import ssl".
Some other post suggested the problem was with the requests package. I then tried sudo apt-get remove python3-requests followed by sudo apt-get install python3-requests also to no avail.
Other information you may need:
pip3 --version gives me the same error reported above.
dpkg -L python3-pip gives me the following information:
/.
/usr
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/not-zip-safe
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/requires.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/entry_points.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/top_level.txt
/usr/lib/python3/dist-packages/pip
/usr/lib/python3/dist-packages/pip/baseparser.py
/usr/lib/python3/dist-packages/pip/__main__.py
/usr/lib/python3/dist-packages/pip/req
/usr/lib/python3/dist-packages/pip/req/req_set.py
/usr/lib/python3/dist-packages/pip/req/req_install.py
/usr/lib/python3/dist-packages/pip/req/__init__.py
/usr/lib/python3/dist-packages/pip/req/req_file.py
/usr/lib/python3/dist-packages/pip/req/req_uninstall.py
/usr/lib/python3/dist-packages/pip/index.py
/usr/lib/python3/dist-packages/pip/status_codes.py
/usr/lib/python3/dist-packages/pip/utils
/usr/lib/python3/dist-packages/pip/utils/setuptools_build.py
/usr/lib/python3/dist-packages/pip/utils/appdirs.py
/usr/lib/python3/dist-packages/pip/utils/outdated.py
/usr/lib/python3/dist-packages/pip/utils/ui.py
/usr/lib/python3/dist-packages/pip/utils/logging.py
/usr/lib/python3/dist-packages/pip/utils/encoding.py
/usr/lib/python3/dist-packages/pip/utils/deprecation.py
/usr/lib/python3/dist-packages/pip/utils/__init__.py
/usr/lib/python3/dist-packages/pip/utils/filesystem.py
/usr/lib/python3/dist-packages/pip/utils/hashes.py
/usr/lib/python3/dist-packages/pip/utils/build.py
/usr/lib/python3/dist-packages/pip/compat
/usr/lib/python3/dist-packages/pip/compat/dictconfig.py
/usr/lib/python3/dist-packages/pip/compat/__init__.py
/usr/lib/python3/dist-packages/pip/compat/ordereddict.py
/usr/lib/python3/dist-packages/pip/models
/usr/lib/python3/dist-packages/pip/models/index.py
/usr/lib/python3/dist-packages/pip/models/__init__.py
/usr/lib/python3/dist-packages/pip/vcs
/usr/lib/python3/dist-packages/pip/vcs/bazaar.py
/usr/lib/python3/dist-packages/pip/vcs/subversion.py
/usr/lib/python3/dist-packages/pip/vcs/mercurial.py
/usr/lib/python3/dist-packages/pip/vcs/__init__.py
/usr/lib/python3/dist-packages/pip/vcs/git.py
/usr/lib/python3/dist-packages/pip/cmdoptions.py
/usr/lib/python3/dist-packages/pip/basecommand.py
/usr/lib/python3/dist-packages/pip/commands
/usr/lib/python3/dist-packages/pip/commands/completion.py
/usr/lib/python3/dist-packages/pip/commands/install.py
/usr/lib/python3/dist-packages/pip/commands/hash.py
/usr/lib/python3/dist-packages/pip/commands/uninstall.py
/usr/lib/python3/dist-packages/pip/commands/__init__.py
/usr/lib/python3/dist-packages/pip/commands/list.py
/usr/lib/python3/dist-packages/pip/commands/search.py
/usr/lib/python3/dist-packages/pip/commands/show.py
/usr/lib/python3/dist-packages/pip/commands/download.py
/usr/lib/python3/dist-packages/pip/commands/wheel.py
/usr/lib/python3/dist-packages/pip/commands/freeze.py
/usr/lib/python3/dist-packages/pip/commands/help.py
/usr/lib/python3/dist-packages/pip/_vendor
/usr/lib/python3/dist-packages/pip/_vendor/__init__.py
/usr/lib/python3/dist-packages/pip/operations
/usr/lib/python3/dist-packages/pip/operations/__init__.py
/usr/lib/python3/dist-packages/pip/operations/freeze.py
/usr/lib/python3/dist-packages/pip/__init__.py
/usr/lib/python3/dist-packages/pip/locations.py
/usr/lib/python3/dist-packages/pip/pep425tags.py
/usr/lib/python3/dist-packages/pip/exceptions.py
/usr/lib/python3/dist-packages/pip/download.py
/usr/lib/python3/dist-packages/pip/wheel.py
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pip3.1.gz
/usr/share/doc
/usr/share/doc/python3-pip
/usr/share/doc/python3-pip/copyright
/usr/bin
/usr/bin/pip3
/usr/share/doc/python3-pip/changelog.Debian.gz
How can I make pip3 work?
NOTE: pip for Python2 works just fine.
================================================
EDIT:
When trying to import setuptools in Python3 I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extern.six.moves import filterfalse, map
File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
#_call_aside
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
callback(dist)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
declare_namespace(pkg)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
When running the following command sed -n '31,37p' < /usr/lib/python3/dist-packages/pip/_vendor/__init__.py in the terminal, I get the following:
try:
__import__(vendored_name, globals(), locals(), level=0)
except ImportError:
try:
__import__(modulename, globals(), locals(), level=0)
except ImportError:
===========================================
EDIT2:
My python3 --version is Python 3.5.2.
List of installed packages obtained running the code ls /usr/lib/python3/dist-packages.
apport
apport_python_hook.py
apt
aptdaemon
apt_inst.cpython-35m-x86_64-linux-gnu.so
apt_pkg.cpython-35m-x86_64-linux-gnu.so
aptsources
AptUrl
apturl-0.5.2.egg-info
beautifulsoup4-4.4.1.egg-info
blinker
blinker-1.3.egg-info
Brlapi-0.6.4.egg-info
brlapi.cpython-35m-x86_64-linux-gnu.so
bs4
cairo
_cffi_backend.cpython-35m-x86_64-linux-gnu.so
chardet
chardet-2.3.0.egg-info
checkbox_support
checkbox_support-0.22.egg-info
CommandNotFound
command_not_found-0.3.egg-info
cryptography
cryptography-1.2.3.egg-info
cups.cpython-35m-x86_64-linux-gnu.so
cupsext.cpython-35m-x86_64-linux-gnu.so
curl
cycler-0.9.0.egg-info
cycler.py
dateutil
dbus
_dbus_bindings.cpython-35m-x86_64-linux-gnu.so
_dbus_glib_bindings.cpython-35m-x86_64-linux-gnu.so
deb822.py
debconf.py
debian
debian_bundle
decorator-4.0.6.egg-info
decorator.py
defer
defer-1.0.6.egg-info
DistUpgrade
easy_install.py
feedparser-5.1.3.egg-info
feedparser.py
feedparser_sgmllib3.py
gi
guacamole
guacamole-0.9.2.egg-info
hpmudext.cpython-35m-x86_64-linux-gnu.so
html5lib
html5lib-0.999.egg-info
httplib2
httplib2-0.9.1.egg-info
idna
idna-2.0.egg-info
janitor
jinja2
Jinja2-2.8.egg-info
jwt
LanguageSelector
language_selector-0.1.egg-info
language_support_pkgs.py
louis
louis-2.6.4.egg-info
lsb_release.py
lxml
lxml-3.5.0.egg-info
mako
Mako-1.0.3.egg-info
markupsafe
MarkupSafe-0.23.egg-info
matplotlib
matplotlib-1.5.1.egg-info
matplotlib-1.5.1-nspkg.pth
mpl_toolkits
networkx
networkx-1.11.egg-info
numexpr
numexpr-2.4.3.egg-info
numpy
numpy-1.11.0.egg-info
NvidiaDetector
oauthlib
oauthlib-1.0.3.egg-info
Onboard
onboard-1.2.0.egg-info
orca
padme
padme-1.1.1.egg-info
pandas
pandas-0.17.1.egg-info
pcardext.cpython-35m-x86_64-linux-gnu.so
pexpect
pexpect-4.0.1.egg-info
PIL
Pillow-3.1.2.egg-info
pip
pip-8.1.1.egg-info
pkg_resources
plotly
plotly-1.9.5.egg-info
problem_report.py
ptyprocess
ptyprocess-0.5.egg-info
pyasn1
pyasn1-0.1.9.egg-info
pyatspi
__pycache__
pycups-1.9.73.egg-info
pycurl-7.43.0.egg-info
pycurl.cpython-35m-x86_64-linux-gnu.so
pygobject-3.20.0.egg-info
pygtkcompat
PyJWT-1.3.0.egg-info
pylab.py
pyparsing-2.0.3.egg-info
pyparsing.py
python_apt-1.1.0.b1_ubuntu0.16.04.1.egg-info
python_dateutil-2.4.2.egg-info
python_debian-0.1.27.egg-info
python_systemd-231.egg-info
pytz
pytz-2014.10.egg-info
pyxdg-0.25.egg-info
PyYAML-3.11.egg-info
Quirks
reportlab
reportlab-3.3.0.egg-info
requests
requests-2.9.1.egg-info
scanext.cpython-35m-x86_64-linux-gnu.so
scipy
scipy-0.17.0.egg-info
sessioninstaller
sessioninstaller-0.0.0.egg-info
setuptools
setuptools-20.7.0.egg-info
six-1.10.0.egg-info
six.py
softwareproperties
speechd
speechd_config
systemd
system_service-0.3.egg-info
tables
tables-3.2.2.egg-info
UbuntuDrivers
ubuntu_drivers_common-0.0.0.egg-info
UbuntuSystemService
ufw
ufw-0.35.egg-info
unattended_upgrades-0.1.egg-info
unity_scope_calculator-0.1.egg-info
unity_scope_chromiumbookmarks-0.1.egg-info
unity_scope_colourlovers-0.1.egg-info
unity_scope_devhelp-0.1.egg-info
unity_scope_firefoxbookmarks-0.1.egg-info
unity_scope_gdrive-0.7.egg-info
unity_scope_manpages-0.1.egg-info
unity_scope_openclipart-0.1.egg-info
unity_scope_texdoc-0.1.egg-info
unity_scope_tomboy-0.1.egg-info
unity_scope_virtualbox-0.1.egg-info
unity_scope_yelp-0.1.egg-info
unity_scope_zotero-0.1.egg-info
unohelper.py
uno.py
UpdateManager
urllib3
urllib3-1.13.1.egg-info
usbcreator
usb_creator-0.3.0.egg-info
wheel
wheel-0.29.0.egg-info
xdg
xdiagnose
xdiagnose-3.8.4.1.egg-info
xkit
xkit-0.0.0.egg-info
xlsxwriter
XlsxWriter-0.7.3.egg-info
yaml
_yaml.cpython-35m-x86_64-linux-gnu.so
This solved it for me:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
try use virtualenv for every specific project not messing with ubuntu subsystem.
I got this error on WSL Ubuntu and the most upvoted solution didn't work for me.
The one that works:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall
Thanks #s_s.411
I solve this problem with the following commands:
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3
type pip3
hash -r
pip3
I ran into the same problem, on Ubuntu 16.04, using the system python 3.5.2 like you, with pip installed via apt (sudo apt install python3-pip) like you, having installed some packages in my home directory with pip3 install --user like you (documented in your chat with hoefling).
The solution was as follows:
Temporarily move away all packages installed with pip3 install --user:
mv ~/.local/lib/python3.5/site-packages{,_backup}
This made pip3 work again, but of course I wanted to keep the packages. (Note: just moving out setuptools was not enough; I am not sure which constellation of packages caused this.)
Install an upgraded pip into home directory:
pip3 install --upgrade --user pip
Now the pip3 command fails (ImportError: cannot import name 'main') because it's still called from the old /usr/bin/pip3 location in the current shell, as indicated by type pip3. To solve this, run:
hash -r
Alternatively, you can always fall back to typing python3 -m pip instead of pip3.
Restore the packages:
mv ~/.local/lib/python3.5/site-packages{_backup/*,}
rmdir ~/.local/lib/python3.5/site-packages_backup
Now pip was working, but python3 -m 'import setuptools' failed with the same exception you saw, AttributeError: '_NamespacePath' object has no attribute 'sort'. This could be solved by uninstalling, then reinstalling the setuptools package in my home directory (uninstalling alone was not enough):
pip3 uninstall setuptools
pip3 install --user --upgrade setuptools
Finally, pip3 and the python3 -c 'import setuptools' are fine.
No module named 'pip._vendor.packaging'
The solution for me was to uninstall the system pipenv (installed with the package manager, pacman), and install pipenv from pip (which is managed with pyenv):
pip install pipenv
I no longer have issues when running pipenv install.
I tried all fixes on this page and it didn't work, finally I found out my virtualenv was broken and I had to reinstall the virtualenv like so
deactivate - deactivate first to be safe
virtualenv --python=/usr/bin/python3.8 /path/to/my_virtualenv_python3
source /path/to/my_virtualenv_python3/bin/activate - activate the env egain
Of course replace /path/to/my_virtualenv_python with your own path and python3.8 with a custom version of python if you don't use version 3.8 :)
Also please note this may or may not remove already installed packages, so just reinstall every requirements.txt you need afterwards.
I also have same problem and I solved it by this command.
pip uninstall pkg-resources==0.0.0
I use an old virtualenv version, it is OK.
The old version is 15.1.0.
I had a similar issue with Debian 11, my Debian has been updated to major releases several times and it looks like some files were not removed. I had to clean them:
# remove pip
sudo apt purge python3-pip
# check that the files don't belong to any package
dpkg -S /usr/share/python-wheels/* /usr/share/python-support/private/*
# remove the files
sudo rm -rfv /usr/share/python-wheels/ /usr/share/python-support/private/
# remove old files since Python is now 3.9
rm -rfv ~/.local/lib/python3.7/
# reinstall pip
sudo apt install python3-pip
And pip worked again.

Python 3 pip upgrade from 7.1.2 to 8.0.1 fails

pip says that I shall consider an upgrade. When I'm doing so and using
python -m pip install --upgrade pip
I get the following UnicodeDecode error message:
C:\Users\Sören>python -m pip install --upgrade pip
Collecting pip
Using cached pip-8.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.1.2
Exception:
Traceback (most recent call last):
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\basecommand.py", line 211, in main
status = self.run(options, args)
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\commands\install.py", line 311, in run
root=options.root_path,
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\req\req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\req\req_install.py", line 673, in uninstall
for path in pip.wheel.uninstallation_paths(dist):
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\wheel.py", line 512, in unique
for item in fn(*args, **kw):
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\wheel.py", line 531, in uninstallation_paths
r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1619, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "C:\Users\Sören\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1616, in get_metadata
return self._get(self._fn(self.egg_info, name)).decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 22366: invalid start byte
You are using pip version 7.1.2, however version 8.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I'm running Python 3 in the 32-bit version on a Windows 10 machine. I don't know if that has anything to do with it, but I had VisualStudio, version 10, installed on my system. Now it is removed.
Kind regards
John
Thanks blackpingus, your answer helped me to find the problem.
The problem was the 'ö' character, which is the name, I am using on Windows. Because of that, this name is also placed in the system path.
A workaround for that problem is to install the package using another user account, which has not any 'umlaute' in his name.
To install updated pip
From start, find the "Command Prompt
Right click on "Command Prompt"
Run as Administrator
Provide the user name and the password if prompted
Now you can upgrade pip: python -m pip install --upgrade pip

Issues installing Tweepy on Ubuntu

I'm trying to install Tweepy on an Ubuntu VM and I'm running into way more issues than I should be. My first step was to successfully get pip installed. After that I tried:
pip install tweepy
which returns:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3020, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 616, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 629, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 807, in resolve
pkg_resources.DistributionNotFound: pip==1.5.4
The most that I can gather from that error message is that it can't find pip version 1.5.4. However, if I ask it whereis pip it returns:
pip: /usr/local/bin/pip2.7 /usr/local/bin/pip /usr/share/man/man1/pip.1.gz
So I know pip is installed. I decided to try the other method listed and do
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
But that only seems to partially install with error messages returning. Trying whereis tweepy after that method returns nothing.
Can anyone make sense of why this simple install isn't working for me?
This issue was resolved by using another fresh Ubuntu VM install and once again trying the manual installation by using
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
For whatever reason, it now works. The answer is officially voodoo.

Resources