ImportError: No module names 'matplotlib' Python 3.3 - python

I'm new to python (started 2 days ago) and I have gotten to the point where I want to use matplotlib for my program. I am using python 3.3 and after I have followed the instructions of installing matplotlib I've gone through the following steps:
sudo apt-get install python-pip
sudo pip install matplotlib
That returned this import error:
ImportError: No module named 'matplotlib'
So after some research I tried this:
sudo apt-get update
sudo apt-get build-dep python-matplot
I'm still getting the same import error. I have found this page here: https://askubuntu.com/questions/427708/matplotlib-error-no-module-named-matplotlib-even-though-it-is-installed
This has given me the impression that I have installed the incorrect version of matplotlib and that I need v1.2 or higher. Can someone explain to me what I need to do to be able to use matplotlib and not get this error with Python 3.3?
I'm currently using Ubuntu 12.04.
Thank you.

On my Mint 17 I just did, with Python 3.4 (would recommend that as you just start with Python, unless you need some library which does not yet support 3.4):
sudo pip3 install matplotlib
Then test the install:
python3
import matplotlib
matplotlib.__version__
Should give you '1.4.0'

I am using python3 installed through anaconda3 on Ubuntu 16.04.
sudo <path to anaconda>/anaconda3/bin/conda install matplotlib
Path to anaconda installation directory can be found using:
conda info --envs

Related

Unable to install pandas or other packages in linux virtual environment

I am unable to install module pandas in my linux vm. I tried all ways to install it, but it says it has version 1.1.5 requirement already satistied. But when I try running the code, it says, no module found. The latest version of python in it is 2.7.3, but I want to install 3.8 or 3.7, but I'm unable to. Where am I going wrong?
Did you try installing python3 from your package manager? You can install python 3.9 from apt using the below command
apt install python3 pip -y
You can also install the below package to use python in the terminal instead of python3 every time
apt install python-is-python3 -y
I cant comment yet so using the answer section, kindly give me an upvote so I can start using the comment feature, sorry for the trouble

How to install matplotlib on python3.4 raspberry pi

I am trying to install matplotlib on python3.4 (the default version on raspberry pi) via pip3 but the installation always fails.
I have tried installing python3.7 but pip3 defaults to installing on python3.4 and I don't know how to change that.
The error message I constantly get is " Beginning with Matplotlib 3.1, Python 3.6 or above is required.". How do I update my python on the pi or install it on python3.4?
Any help appreciated.
Having just looked at older releases ( https://pypi.org/project/matplotlib/#history ), I think 2.2.4 was the last version to work on Python 3.4
You can install a specific version of the library using the command
pip install matplotlib==2.2.4
Use the package manager of the distribution :
sudo apt install python3-matplotlib
The dependencies should be OK there.
You can just use
sudo pip3 install matplotlib
or for a local instlal of the lib
pip3 install --user <your_username> matplotlib

from matplotlib import style ImportError: cannot import name 'style'

I am receiving the following error message
ImportError: cannot import name 'style'
when I run
from matplotlib import style
I am using ubuntu and have tried running it with python3 and python.
I have version (1.3.1) of matplotlib installed, which is the most up-to-date that apt-get installs. I have installed numpy and installed matplotlib with python3. No joy.
Has anybody else been having the same issue ?
sudo pip install --upgrade matplotlib
Did the trick. Although on my machine it initially threw up some issues. There are a number of helpful suggestions on this thread for anyone else having the issue
ubuntu 14.04, pip cannot upgrade matplotllib
You can also use pip install --user --upgrade matplotlib
Using sudo is deemed unsafe as you're allowing pip to execute code from the internet as root.
Using --user :
..makes pip install packages in your home directory instead, which doesn't require any special privileges Purpose of --user
More information on this here: What are the risks of running 'sudo pip'?
I had the same problem using Anaconda and IPython 3.1. You can update matplotlib to its latest version after you have installed Anaconda. Just remind that you may want to use the installer for Python 3. You will find the style module by using both the matplotlib library and matplotlib.pyplot.

Python ImportError: no module named os

Trying to upgrade matplotlib as in this post, I ran
export PYTHONHOME=/usr/lib/python2.7/
sudo easy_install -U distribute
sudo pip install --upgrade matplotlib
Now whenever I try to run python I get ImportError: no module named os. What happened? Please help me. I'm on OS X 10.9.5.
The issue was changing PYTHONHOME, which could not find any modules because I have python running out of a user directory /Users/alavin89/Library/Python/2.7/lib/python/site-packages. Check the python path by running echo $PYTHONPATH.
The fix:
unset PYTHONHOME
sudo pip uninstall matplotlib
pip uninstall matplotlib
pip install --user matplotlib
Note: running uninstall again w/o sudo is to double-check it worked properly.
Use Anaconda.
https://store.continuum.io/cshop/anaconda/
It has every Python package you could possibly think of - including matplotlib - it updates them all at once as well.

Installing wxpython on ubuntu 14.04

When I try to open PlayOnLinux from the commandline, I get this error:
Looking for python... 2.7.8 - selected
Traceback (most recent call last):
File "mainwindow.py", line 31, in <module>
import wxversion
ImportError: No module named wxversion
Nearly every forum post I have found has suggested I install wxPython, then links here or to some other wxpython wiki page. Unfortunately, the entire wxpython wiki website currently says "wxPyWiki is down for troubleshooting" right now.
I found this StackOverflow question, which is basically the same as mine. I tried all the lower-voted comments, and they all appear to work, but import wx still fails. When I tried the top-rated comment in that thread, I got to step 7 successfully, but then it says
In file included from scr/helpers.cpp:16:0:
include/wx/wxPython/wxPython_int.h:19:19: fatal error: wx/wx.h: No such file or directory
#include <wx/wx.h>
compilation terminated
If anyone has any suggestions for how I can properly install wxPython on Ubuntu, they would be greatly appreciated.
EDIT: sudo pip install wxPython tells me it's already installed ("Requirement already satisfied") and suggests I use --upgrade. It's not installed, import wx still fails.
EDIT: sudo apt-get install wxpython gives the error Unable to locate package wxpython
EDIT: I tried sudo apt-get install python-wxglade and it appeared to work, but playonlinux still gives the same error and import wx still fails.
EDIT: I tried uninstalling and reinstalling playonlinux and python-wxversion. Both remove/install appeared successful, but I still get the same No module named wxversion error.
EDIT: I tried the solutions posted here (except for reinstalling the OS). They did not work. I'd rather not reinstall Ubuntu.
Before that install gtk3
$ sudo apt-get install libgtk-3-dev
If you are facing problem to install wxpython on Python3 please use this command to install wxpython
$ pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython
By this command you can install latest wxPython4 version.
If you are using Windows or macOS
$ pip install -U wxpython
If you are using Anaconda/Conda
$ conda install -C anaconda wxpython
The answer about installing "python-wxgtk2.8" is correct. But that's if you want to install 2.8, if you want 3.0 in 14.04, you can get it by following this post. I have done that, and have wx 3.0 installed.
All you need is:
sudo apt-get install python-wxgtk3.0
Try installing python-wxglade.It must have all necessary wx modules inside.
Check Synaptic for wxPython 3.x to see if you can install it that way. According to https://www.playonlinux.com/en/news.html, version 4.2.5 of PlayOnLinux supports wxPython 3. If you can't get Synaptic to find a copy of wxPython 3, then you should refer to the official build instructions found here:
http://wxpython.org/builddoc.php
wxPython package is named "python-wxgtk2.8" for wxWidgets 2.8
Install it: sudo apt-get install python-wxgtk2.8
I tried many things, so I'm not sure if this is the minimum set of pre-requisites.
$ sudo apt-get install libwxbase3.0-dev libwxgtk3.0-dev wx-common libwebkit-dev libwxgtk-webview3.0-dev wx3.0-examples wx3.0-headers wx3.0-i18n libwxgtk-media3.0-dev
Then I pip installed the Phoenix version:
$ sudo pip install --upgrade --pre -f http://wxpython.org/Phoenix/snapshot-builds/ --trusted-host wxpython.org wxPython_Phoenix
This installs wxPython via pip, but I don't think it addresses your issue with wxversion.

Categories