I want to install matplotlib via pip. However, I run into circular issues and at certain point I got stuck. Running pip in the terminal produces:
Traceback (most recent call last):
File "/usr/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 3080, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3066, in _call_aside
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3093, in _initialize_master_working_set
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 651, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 952, in require
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 839, in resolve
pkg_resources.DistributionNotFound: The 'pip==1.5.4' distribution was not found and is required by the application
I tried to fix this with easy_install, but it produced the following error message:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3080, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3066, in _call_aside
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3093, in _initialize_master_working_set
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 653, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 666, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 839, in resolve
pkg_resources.DistributionNotFound: The 'setuptools==3.3' distribution was not found and is required by the application
Running sudo apt-get install python-setuptools says that I already have the newest version.
My OS is Ubuntu 14.04. I have tried many different approaches to fix the issue and probably ended up doing even further harm. I don't recall everything I did and how I ended up at this stage, so unfortunately cannot give further info.
My objective is to have matplotlib installed in the end and have a stable state of all my python related libraries. Any solution will work, so I don't mind reinstalling everything or whatever would fix the issue.
UPDATE
Running sudo apt-get build-dep python-matplotlib produces
Reading package lists... Done
Building dependency tree
Reading state information... Done
Picking 'matplotlib' as source package instead of 'python-matplotlib'
E: Unable to find a source package for matplotlib
Whereas sudo apt-get install python-matplotlib produces
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-matplotlib is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
However, matplotlib is still not found from python.
Try:
sudo apt-get build-dep python-matplotlib
This should install the dependecies that matplotlib needs via the Ubuntu package management system (because a lot of those dependencies are not trivial to install with pip), enabling you to:
pip install matplotlib
Source: Matplotlib documentation
I have used this process on both Ubuntu 14.04 and Kubuntu 15.10 to install the newest, stable matplotlib (in virtual environments, but that shouldn't make a difference).
Related
So I've been using linux mint mate for a while, and everything was working fine.
So as I got a new notebook, I installed the new version of linux mint (19.2 - Tina) alongside the windows 10. Everything went right, I think.
Now, I'm trying to get it ready for use, and it's not working.
It supposedly came with both versions of python:
Python 2.7.15+
Python 3.6.8
But when I tried to run a simple hello world, but importing the essentials packages for me, something like this
import numpy as np
import math #as ma
import matplotlib.pyplot as plt; plt.switch_backend('agg')
import sys
import pandas as pd
import seaborn as sns; sns.set()
import powerlaw as pl
from itertools import zip_longest
import csv
import os
print('hello world')
It didn't even recognize the numpy package, and I got the following:
Traceback (most recent call last):
File "testes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
So I went to this website and tried following the tutorial
https://packaging.python.org/tutorials/installing-packages/#id18
But when I tried to install numpy the result was as bellow:
(tutorial_env) jheniffer#jheniffer-5480:~/Dropbox/teste_cros_bi$ pip install python3-numpy
Collecting python3-numpy
Exception:
Traceback (most recent call last):
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 795, in get_page
resp.raise_for_status()
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/python3-numpy/
I don't know what should I do to get this running,
how should I proceed to install everything, because I thought that the basic packages, like numpy for example, was already installed, and every other time that I tried installing something by pip (on my previous laptop) it worked with just
pip3 install python3-numpy
I tried the option without pip, it installed successfully
(tutorial_env) jheniffer#jheniffer-5480:~/Dropbox/teste_cros_bi$ sudo apt install python3-numpy
[sudo] password for jheniffer:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
gfortran python-numpy-doc python3-dev python3-nose python3-numpy-dbg
The following NEW packages will be installed:
python3-numpy
0 upgraded, 1 newly installed, 0 to remove and 287 not upgraded.
Need to get 1.943 kB of archives.
After this operation, 10,9 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-numpy amd64 1:1.13.3-2ubuntu1 [1.943 kB]
Fetched 1.943 kB in 4s (528 kB/s)
Selecting previously unselected package python3-numpy.
(Reading database ... 308507 files and directories currently installed.)
Preparing to unpack .../python3-numpy_1%3a1.13.3-2ubuntu1_amd64.deb ...
Unpacking python3-numpy (1:1.13.3-2ubuntu1) ...
Setting up python3-numpy (1:1.13.3-2ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
But when I tried to run the hello word code, I got this message again
(tutorial_env) jheniffer#jheniffer-5480:~/Dropbox/teste_cros_bi$ python3 testes.py
Traceback (most recent call last):
File "testes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
It looks like you may be using the apt package name in pip as opposed to the name of the PyPi package. First, check the default versions for pip and python on your system. This can be done using pip --version and python --version. If both are defaulting to Python 2.7 (which they very well might be), I would strongly recommend using Python 3.6 if possible, as Python 2.7 will reach EOL in 2020.
You can do this explicitly by using pip3 and python3 via the command line. To install numpy for Python 3, use pip3 install numpy. Keep in mind that this will only install it for Python 3, so if you spin up Python 2.7 interpreter, it will not be installed.
In the future, if you want to find the name of a PyPi package for install, you can do pip search {QUERY}, like pip search numpy for example.
I'm trying to use facebook research's Detectron. When I run it, it gives me the following error:
libpng warning: Application built with libpng-1.6.21 but running with 1.5.12
Traceback (most recent call last):
File "tools/infer_simple.py", line 147, in <module>
main(args)
File "tools/infer_simple.py", line 139, in main
kp_thresh=2
File "/home/sid/DETECTRON/detectron/lib/utils/vis.py", line 391, in vis_one_image
fig.savefig(os.path.join(output_dir, '{}'.format(output_name)), dpi=dpi)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1834, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2267, in print_figure
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2595, in print_pdf
file.finalize()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 595, in finalize
self.writeImages()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1430, in writeImages
ob.id, smaskObject)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1416, in _writeImg
self._writePng(data)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1366, in _writePng
_png.write_png(data, buffer)
RuntimeError: Could not create write struct
I'm running Ubuntu 16.04. I don't know where the application is finding the libpng 1.5.12 version. I could not find it in my system. I installed libpng16-16. It still gives me the same error. I tried out other solutions suggested on the platform but they didn't work
I guess the problem is that you sudo pip installed matplotlib and that the libpng version that is shipped with the manylinux installation package of matplotlib is confused with the libpng version that was installed by apt. I recommend using matplotlib inside a virtual environment.
# create venv
virtualenv ~/matplotlib-venv
# activate venv
source ~/matplotlib-venv/bin/activate
# install matplotlib
pip install matplotlib
pip install <everything else you need>
# run your script
python ~/path/to/your/srcript.py
quick thing: YES I KNOW THERE IS ANOTHER POST ON THIS, but its answers do NOT solve my issue.
So I installed this package called hangups on my raspberry pi. It ruined my pip installation and gave me the error below. However if you google this error, you will come to a post that does have a solution: re installing pip. I had done this several times; Once reinstalling pip from apt, 2nd time from get-pip.py, last by reinstalling python3. Irregardless, none of these methods solved my error (Oh and i also must mention that i did try the easy_install reinstallation of pip but that fails too). Nothing seems to work. My theory is that some repository somewhere is not updated because the error message points to some ancient version of pip (<= 2) (on my mac pip is at 9 running same version of python 3) and for some reason, pip has this dependency that isnt there just disables my pip binary. I would install them, but (lol) i dont have pip. The error is below. How do I fix this?
please comment if you need more information. Thanks!!!
/usr/local/lib/python3.4/dist-packages/requests/__init__.py:80:
RequestsDependencyWarning: urllib3 (1.22) or chardet (2.3.0) doesn't
match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
Yeah ok so for future reference kids, easy_install does (like pip) have a python 3.x version. Just do sudo easy_install3 -U pip.
I updated setuptools using:
easy_install -U setuptool
This ran fine. I then realized I did not want to use the most recent version of setuptools and deleted setuptools-18.3.2-py2.6.egg file from /usr/lib/python2.6/site-packages. After I did this I am getting the following errors when trying to install anything using easy_install shown below.
easy_install ReviewBoard-1.7.6-py2.6
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2659, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools>=0.7
Looks like ReviewBoard needs setuptools as a dependency. When you ran easy_install ReviewBoard-1.7.6-py2.6, it would have detected that this dependency is already installed but actually it wasn't.
One reason could be that deleting the .egg file was not the complete process of getting rid of a package installed with easy_install. You also need to remove the corresponding line from site-packages/easy-install.pth. Refer: https://stackoverflow.com/a/1233282/4045754
I have a bit of a problem. I am on Debian Squeeze, and I want to install sqlite2. The problem is, when I try with:
# pip install pysqlite2
I get:
Downloading/unpacking pysqlite2
Could not find any downloads that satisfy the requirement pysqlite2
No distributions at all found for pysqlite2
Storing complete log in /root/.pip/pip.log
The same error I get when I try with:
# pip install python-pysqlite2
I also tried with easy_install:
# easy_install pysqlite2
Searching for pysqlite2
Reading http://pypi.python.org/simple/pysqlite2/
Couldn't find index page for 'pysqlite2' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pysqlite2
Best match: None
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 8, in <module>
load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1712, in main
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1716, in <lambda>
File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 211, in run
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 434, in easy_install
File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/package_index.py", line 475, in fetch_distribution
AttributeError: 'NoneType' object has no attribute 'clone'
I also tried with downloading the pyslite2 package from here, and when I try with:
# dpkg -i python-pysqlite2-dbg_2.6.0-1_amd64.deb
I get the following error:
Selecting previously deselected package python-pysqlite2-dbg.
(Reading database ... 144103 files and directories currently installed.)
Unpacking python-pysqlite2-dbg (from python-pysqlite2-dbg_2.6.0-1_amd64.deb) ...
dpkg: dependency problems prevent configuration of python-pysqlite2-dbg:
python-pysqlite2-dbg depends on python-pysqlite2 (= 2.6.0-1); however:
Package python-pysqlite2 is not configured yet.
python-pysqlite2-dbg depends on python-dbg; however:
Package python-dbg is not installed.
dpkg: error processing python-pysqlite2-dbg (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python-pysqlite2-dbg
I would really appriciate help for this.
Thanks in advance!
Just run apt-get install to install all missing dependencies:
apt-get -f install