There are similar questions posted on Stackoverflow that did not seem to work for me. I am trying to install the pylab module for Python. I am using OSX. I have Python 2.7, 3.6, and 3.7 installed and have been running IDLE from 3.6. I also installed Anaconda. It looks like I have the modules and libraries I need here:
/Users/[username]/anaconda3/lib/python3.6/site-packages/matplotlib
There is also a pylab.py in that same site-packages directory.
But when I run a simple Python program with:
from pylab import plot, show
I get this error message:
Traceback (most recent call last):
File "/Users/[username]/Desktop/Python/graph.py", line 1, in <module>
from pylab import plot, show
ModuleNotFoundError: No module named 'pylab'
Not sure what I am doing wrong.
Related
I'm rather new to coding, so please bare with me if I'm not using the optimal terminology to ask this question. I've installed and set up python on my Mac using pyenv based on the following link:
https://opensource.com/article/19/5/python-3-default-mac
I'm currently trying to execute a program, but I receive a ModuleNotFoundError on Numpy upon execution.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
I've checked via terminal and ensured numpy is installed, I went through the pyenv source files and confirmed numpy is there, and tried the "python -mpip install numpy" method to no avail. I'm not sure what to do at this point, so any of your suggestions would be greatly appreciated! Thank you!
Recently, when I use pip to install python modules, I will get an error saying that the module has not been downloaded when I run it in the IDLE. However, when I run the same script in the terminal, it works fine. What is this error and how can I solve it?
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import gspread
ModuleNotFoundError: No module named 'gspread'
Probably you have different versions of python installed.
The version you used pip to install new modules is different from the version you access with IDLE.
This is the error I get when trying to import numpy on opening python (2.7.8):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
This is the path of my python binary /usr/local/bin/python
This is the path of pip /usr/local/bin/pip
Also, when I put in pip freeze I found the numpy package numpy==1.8.0rc1
I have looked at other relevant questions, but I'm not able to diagnose the cause. I'm guessing it might be some problem in PATHS. Where do I start?
As Akshat pointed out in the comments above, I had multiple versions of Python installed. This could have been the effect of using homebrew and/or macports in the past. I followed the steps detailed in Too many pythons on my Mac OS X Mountain Lion
and did a fresh install of Python 2.7.12 I was then able to reinstall pip and the packages subsequently.
I am trying to import matplotlib and plotly in my python script to plot a simple distribution. Earlier when I was running the script, it was displaying nothing on the command-line and it seemed that it was simply processing the import statement.
To debug it, I upgraded python using brew install python after that and did a pip install --upgrade pip after that. Using the upgraded pip, I made sure that matplotlib and plotly are installed. But, upon running the script, I am getting the following error on command-line:
$ python script.py
Traceback (most recent call last):
File "script.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 110, in <module>
import io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Can someone please help me resolve this issue?
Thanks in advance.
I found a similar SO issue for Selenium. The problem appeared to be a python issue after updating and the solution there was to type hash -r python in the terminal. Worth a try.
So I am trying to work with Astropy and I definitely downloaded it. However, I am getting an error. I am trying to work in Python 2 rather than Python 3.
The code was just:
import astropy
astropy.test()
This is the error given:
Traceback (most recent call last):
File "/Users/....../Random.py", line 1, in <module>
import astropy
ImportError: No module named astropy
Try a few things at the shell to examine your environment and possibly understand your problem:
which python
which conda
conda list
Basically, the fix was removing Python 3.4, deleting directory, reinstalled 2.7 and Pypm Astropy. Not sure exactly what happened but that was the fix...