简体   繁体   中英

ImportError No module named 'matplotlib'

I have Python 3.6 installed with Matplotlib and I created a small program, which runs and plots the graph fine. Now, I want to export the data from this program into a MySQL database. I downloaded MySQL/Python connector, which only supports Python 3.4. So, I installed Python 3.4 as well. Now,I have two Python installed. My program runs fine if I do

python test.py

If I go into 3.4 installation directory and run the same command, it fails with the error 'No module named matplotlib'. If I do

pip install matplotlib

from 3.4 directory, then it says 'requirements already satisfied'. Any idea what am I missing here?

Calling pip like this, it's not about the current directory, but just about your system paths. If you want to be sure, you can always go to python-env/Scripts/pip (your python-binary would be at python-env/python ).

You need to keep your installs separate. The path statement is getting messed up. I would suggest getting anaconda . Once you install it you can get all the packages and dependencies in one action.

conda create -n py34project python=3.4 matplotlib ipython other_package

then easily get python 3.6

conda create -n py36project python=3.6 matplotlib ipython other_package

you can use: source activate py36project to enter the environment (which will fix the path problem) and leave the environment with source deactivate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM