I have two python compilers on my Ubuntu 14.04 VM. I have installed matplotlib as
pip install matplotlib
But the matplotlib cannot be used from python3.It can be used from python2.7
If I use import matplotlib.pyplot as plt inside my script test.py and run it as
python3 test.py
I get the error
ImportError: No module named 'matplotlib'
How can this be fixed.
Use pip3 to install it:
sudo apt-get install python3-pip
sudo pip3 install matplotlib
You can install the package from your distro with:
sudo apt-get install python3-matplotlib
It will probably throw an error when you import matplotlib, but it is solved by installing the package tkinter with:
sudo apt-get install python3-tk
Related
I am attempting to install matplotlib and scipy to python, and using pip to do so. However when I attempted to install scipy with pip install scipy --myuser I received the message:
invalid requirement '--myuser'
Previously I had installed numpy using pip with
python get-pip.py —myuser
and
pip install numpy —myuser
This worked fine, so I am unsure what the problem is here.
This is frustrating as I would like to use python from the terminal rather than from my Windows desktop.
If you want to install to user try the below mentioned command:
pip install --user scipy
Here is the help from pip command:
pip install --help
--user Install to the Python user install directory for
your platform. Typically ~/.local/, or
%APPDATA%\Python on Windows. (See the Python
documentation for site.USER_BASE for full
details.)
You should be able to install it without the use of the --myuser argument.
sudo python3 -m pip install scipy
sudo python3 -m pip install matplotlib
or all in one
sudo python3 -m pip install scipy matplotlib
Try this:
sudo python3 -m pip install scipy matplotlib
After command pip install mpl_toolkits I receive next error:
Could not find a version that satisfies the requirement mpl_toolkits (from versions: )
No matching distribution found for mpl_toolkits
I tried to google, but nothing helps. How can I solve this?
It is not on PyPI and you should not be installing it via pip. If you have matplotlib installed, you should be able to import mpl_toolkits directly:
$ pip install --upgrade matplotlib
...
$ python
>>> import mpl_toolkits
>>>
It doesn't work on Ubuntu 16.04, it seems that some libraries have been forgotten in the python installation package on this one. You should use package manager instead.
Solution
Uninstall matplotlib from pip then install it again with apt-get
python 2:
sudo pip uninstall matplotlib
sudo apt-get install python-matplotlib
python 3:
sudo pip3 uninstall matplotlib
sudo apt-get install python3-matplotlib
if anyone has a problem on Mac, can try this
sudo pip install --upgrade matplotlib --ignore-installed six
I can't comment due to the lack of reputation, but if you are on arch linux, you should be able to find the corresponding libraries on the arch repositories directly. For example for mpl_toolkits.basemap:
pacman -S python-basemap
Use pip install mpl_toolkits.clifford
I am trying to use the qrtools module with Python 3.4.2 on my Raspberry Pi 2, however it cannot run as I don't have the zbar module installed.
Trying
pip-3.2 install zbar
Gives the error message shown in the picture
sudo pip-3.2 install zbar
gives a similar error
Any ideas?
(I do have it installed with Python 2.7)
UPDATE: Both libzbar-dev and python3-dev are up to date. Still...
No module named 'zbar'
assuming you're using a debian derivative (like ubuntu), you need to install zbar's developement package, which contains the header file zbar.h
$ sudo apt-get install libzbar-dev
for redhat/fedora systems:
$ sudo yum install zbar-devel
and probably python's dev package too:
$ sudo apt-get install python3-dev
or you can use pip install zbar-py
https://pypi.org/project/zbar-py/
Try the following code after entering sudo mode:
yum install zbar-devel
This should work for fedora.
Bumping #herve solution
On ubuntu and on Mint
sudo apt-get install python-zbar libzbar-dev python-qrtools
pip install libzbar-cffi==0.2.1
This is on CentOs 6.6. I am trying to set up a scientific python environment. I want to avoid Anaconda. When trying to install matplotlib, I get "ImportError: No module named pkg_resources". Full install history:
sudo yum install gcc-c++.x86_64
sudo yum install gcc
sudo yum install atlas atlas-devel lapack-devel blas-devel
sudo yum install python-devel
sudo pip install numpy
sudo pip install scipy
sudo pip install pandas
sudo pip install matplotlib
At the last step, I get the message
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
Then I do
sudo pip install --upgrade distribute
which installs distribute-0.7.3, setuptools-18.0.1. Then:
sudo pip install matplotlib
which results in:
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Any ideas?
Update
After the above steps, setuptools and pip are broken in this installation. From a python shell, doing help() followed by modules does not list setuptools. A search in the filesystem for setuptools directories reveals:
/usr/lib/python2.6/site-packages/setuptools-18.0.1.dist-info/
while the setuptools.pth file in /usr/lib/python2.6/site-packages/ contains a pointer to the non-existent ./setuptools-0.6c11-py2.6.egg-info.
At the same time, there is a directory
/usr/share/doc/python-setuptools-0.6.10/
After all this, pip no longer works.
#pavan they said CentOS, so apt is unlikely to help them.
They could, though, do :
yum remove python-setuptools
yum install python-setuptools
(my also need to reinstall pip: yum install python-pip )
And that might fix the problem.
Try this for OS supporting apt-get (Ubuntu etc)
sudo apt-get install python-pkg-resources python-setuptools --reinstall
Try install python-pip (and dependencies):
yum install python-pip
This solved my problem (Centos release 6.8).
I am getting this error when trying to install ggplot in Python:
ImportError: cannot import name unpack_url
I am using the following command:
sudo pip install ggplot
This error is in a linux environment, running fedora 21.
Looks like you might need to update your version of pip itself.
Entertainingly, you can upgrade pip using pip, as per the docs:
On Debian and Ubuntu:
sudo apt-get install python-pip
On Fedora:
sudo yum install python-pip