Unable to install matplotlib (virtualenv) - python

This is my first question so apologies about format etc.
I'm trying to do the python exercise on http://newcoder.io/dataviz/part-0/ and I'm attempting to install the pre-requisites for working within a virtualenv.
At the stage
(DataVizProj)$ pip install numpy
(DataVizProj)$ pip install matplotlib
It seems to install fine. However on testing matplotlib within python itself (running a python terminal and then trying "import matplotlib") I am getting the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
I have also tried sudo apt-get build-dep matplotlib but every time I am getting the above error. I have googled to no avail - can anybody assist?
P.s. I am using Ubuntu

Related

How to run python script with library inside Kernell terminal?

I'm trying to run python script from terminal, but it's giving me error.
I already installed from linux terminal library sympy 'pip install sympy'. But still it doesn't work
This error i get when trying to run python script file.
Traceback (most recent call last):
File "script.py", line 2, in <module>
from sympy import symbols, diff
ModuleNotFoundError: No module named 'sympy'
Are you using two versions of Python?
python3.x uses pip3, and python2.x uses pip
1) Install pip3 on your system.
sudo apt install python3-pip
2) Install sympy by running
pip3 install sympy
3) Open python3 shell (run "python3" on your terminal) and import the necessary libraries
from sympy import symbols, diff

Trouble installing Adafruit's DHT11 Python library

I followed these instructions to install the Adafruit DHT11 library (https://github.com/adafruit/Adafruit_Python_DHT):
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
And I found the library installed under /home/pi (I'm working with a Raspberry Pi 3). The file I want to fun is in /home/pi/Desktop so I move the library into that directory. However, I still can't run my python file properly. This is the error I'm getting:
Traceback (most recent call last):
File "sensorRead.py", line 4, in <module>
import Adafruit_DHT
ImportError: No module named 'Adafruit_DHT'
How do I get rid of this error? And where should I move my file (or the library) so the library will work? Thank you.
I fixed it. I moved my file into Adafruit_Python_DHT/examples and ran it with the python sensorRead.py command. To be honest, I don't know why it works when I put it into examples, but it does.

Trying to install J3DView

After entering the following in the command line:
sudo apt-get install python3 python3-dev python3-pip
sudo pip3 install cx_Freeze Cython PyOpenGL PyOpenGL_accelerate
sudo python3 setup.py install_exe
The last command gives me this error:
Could not import cx_Freeze. Building executable not possible.
Traceback (most recent call last):
File "setup.py", line 13, in <module>
from Cython.Build import cythonize
ImportError: No module named 'Cython'
Any ideas why?
I'm using Linux Mint 17.3 'Rosa' Cinnamon 64-bit.
[EDIT]
This problem was a complete mess and I still have no clue what happened before. I have given up trying to get Python to work, as I have found an application that does the same thing as the Python application I was trying to get working. It's such a pain.

import matplotlib error on mac

Um... I wanted to import matplotlib in Python IDLE, but it said
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
I've already tried pip thing and the conda thing in terminal.
It said
# All requested packages already installed.
# packages in environment at /Users/Dan/anaconda:
Then! what's the problem here?
You may have installed Matplotlib to Python 2.7 and not Python 3.6. To install it to Python3 you need to use pip3:
pip3 install matplotlib
Then open python3.6 from your terminal (not idle) and try importing matplotlib from there. This way you can use any text editor you wish, and run your code from the terminal.
I had the same issue using the same command in IDLE. I just figured it out. go to your terminal and enter:
pip3.6 install matplotlib
I was using pip3 instead of pip3.6

I'm having troubles getting pybrain working through anaconda

Here is my problem:
After I managed to install anaconda (having python 3.4), I apparently managed to install pybrain too. But when i use 'import pybrain' from anaconda or from the terminal too I get this error:
>>> import pybrain
Traceback (most recent call last):
File "<ipython-input-2-0fb7233d2a8c>", line 1, in <module>
import pybrain
File "//anaconda/lib/python3.4/site-packages/PyBrain-0.3-py3.4.egg/pybrain/__init__.py", line 1, in <module>
from structure.__init__ import *
ImportError: No module named 'structure'
Simply running sudo pip3 install git+https://github.com/pybrain/pybrain.git worked for me after having the same issue.
The version up on PyPi isn't Python 3 compatible.
Installing the latest commit directly using pip3 should take care of your old package (from PyPi) as well.

Categories

Resources