I'm running on a mac and having an issue with trying to get Pillow working.
My versions are:
python - 2.7.6
pip - 9.0.1
Pillow - 4.0.0
I ran:
pip install Pillow
pip install PIL
pip install numpy
I have uninstalled all and re-tried; but nothing seems to be working.
I use:
from PIL import Image
or
import Image
both of which do not work. When I run "pip show --files Pillow" all my PIL and Pillow files show up.
I also tried to install cv2 using the directions posted here: http://www.mobileway.net/2015/02/14/install-opencv-for-python-on-mac-os-x/
import cv2
I get this as my error:
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
>>> import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Image
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
Any suggestions on what I am doing wrong?
I've been doing some hardcore research on this and finally got something to work. I may still have (accidentally) more than one python running, but i ran this command:
sudo easy_install http://dist.plone.org/thirdparty/PIL-1.1.7.tar.gz
And now "from PIL import Image" works!
I found this answer via this question regarding virtualenv. Though, I did not end up using virtualenv, it still led me to a resolution.
The problem with installing PIL using virtualenv or buildout
I spent the last few hours puzzling over a similar issue and finally was able to get modules to work by copying the file into the python library's folder where all the other modules are stored (I'm using anaconda).
Try double-checking where your modules are being installed to.
Related
Am having issues importing pandas on python3 on my raspberry pi. Whatever I try, I get the following error:
pi#raspberrypi:/ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
ModuleNotFoundError: No module named 'pandas.util'
It works fine on Python 2.7. I am getting errors with Python 3.7.3.
I searched Google and tried everything in the following post:
ImportError: No module named pandas
Some of the things I’ve tried are below - none have helped - I still get the error.
pip3 install pandas-util
pip3 install pandas.util
sudo apt-get install python3-wheel
sudo python3 -m pip install pandas
pip3 install pandas --upgrade
I've also tried uninstalling and reinstalling numpy and pandas - still get this error just with a basic import statement.
Any help would be appreciated as this is driving me insane!!
Cheers!
Try with
python3 -m pip install --force-reinstall pandas
This will ensure two things:
it will use the pip executable that belongs to the used Python executable, so that there is no accidental installation by another pip.
it will properly re-install Pandas.
Note that it doesn't re-download the Pandas package (it will use a cached version) if the version on PyPI hasn't changed between now and the previous installation. If that is a potential problem (incorrect cached file, for example), add the option --no-cache-dir to pip install.
Summary of problem:
Using the python interpreter, I type import pyPDF2 and get a ModuleNotFound error even though I have installed the pyPDF2 module:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyPDF2'
What I have tried:
I am using Windows 10. I am new to python. I have installed Python 3.8.3 to a C:\Python38 folder. I have installed pyPDF2 via 'pip install pyPDF2'. The windows path includes the folders: C:\Python38\Scripts\;C:\Python38\.
At the windows Command Prompt I type 'python' and get:
c:\>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
At the python interpreter prompt I type 'import pyPDF2' and get:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyPDF2'
>>>
Note: There is installed an old version of python 2.7 from an ArcGIS install. Could that be causing a conflict? If not, I would rather not uninstall that version since it goes with ArcGIS, which I use.
What I am really trying to do is to automate the concatenation of 7,696 pdf files into 104 pdf files. So far my program looks like this:
import os
from pyPDF2 import PdfFileMerger
source_dir = os.getcwd()
merger = PdfFileMerger()
for item in os.listdir(source_dir):
if item.beginswith('District001_Pg'):
merger.append(item)
merger.write('District001.pdf')
merger.close()
Any help anyone is able to provide will be greatly appreciated!
If you want to run 2 different versions of python in the same machine without having conflicts, you can use VirtualEnv. Here is a document which I found on the web to get you started.
https://www.freecodecamp.org/news/installing-multiple-python-versions-on-windows-using-virtualenv/
For some reason I'm getting this error when trying to import gevent inside my docker container:
# python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/gevent/__init__.py", line 51, in <module>
from gevent.hub import get_hub, iwait, wait
File "/usr/local/lib/python2.7/dist-packages/gevent/hub.py", line 31, in <module>
from gevent._util import _NONE
ImportError: cannot import name _NONE
>>>
Which is odd because _util.py exists, it's in the dist-packages/gevent directory. When I did a pip install on another system, it works fine.
Anyone have any ideas what might be going on?
Have you upgraded gevent package recently or maybe installed it over old version?
I ran pip install --ignore-installed gevent to update old version of this package in my virtualenv, and then this error starts to appear.
I fixed it with pip uninstall gevent (two times to completely remove it) followed by pip install gevent.
I think you import gevnet this module is not you see it.
you can print something in you _util.py module.
if nothing print, I guess "/usr/local/lib/python2.7/dist-packages/gevent/hub.py" import _util is not in /usr/local/lib/python2.7/dist-packages/gevnet, and you can try to print sys.path to find real import path and fix it.
In my Method:
uninstall gevent.
use a another system gevnet or virtualenv package,and copy to you real(I guess you have a env path like '/usr/local/lib64')
exec python -c 'import gevent' test is ok.
So i wanted to use the Quandl package to learn some data processing. I installed Quandl in the pycharm package, and it worked out pretty well.
import Quandl, math
and then, i use the Quandl to get some data from the internet
data = Quandl.get('some form of data')
But then when i tried to run the python script
bash-3.2$ python Regression.py
Traceback (most recent call last):
File "Regression.py", line 2, in <module>
import Quandl, math
ImportError: No module named Quandl
In my Pycharm interpreter, i have 4 different types:
-2.7.11 (/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7) I installed Quandl here
-3.5.1 (/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/bin/python3.5) I also installed it here
-2.6.9 (/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6) It has an error to install packaging tools
-/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Permission denied for installing
When i tried to import Quandl in the terminal through python shell, i also retired an error
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Quandl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Quandl
I also tried the same thing for Simple CV, it also says that it's not in the module, even though I've already installed it both in 3.5 and 2.7.
from SimpleCV import Camera
cam = Camera()
while True:
img = cam.getImage()
img = img.binarize()
img.drawText("Hello World")
img.show()
bash-3.2$ python simplecv.py
Traceback (most recent call last):
File "simplecv.py", line 1, in <module>
from SimpleCV import Camera
ImportError: No module named SimpleCV
For installing 'pip', i also had an error installing it in the Pycharm terminal. I've already asked a question about it Installing pip in Pycharm 2016.3
Try to install it using pip2.7. I suspect that you are trying to execute the script with python3 (python command), however, your python interpreter in pyCharm is python2.7.
If you keep getting errors I suggest you to research a bit about virtualenvs, as it can help you had your several dependencies and interpreters easly organized by proyect. (PyCharm has support for virtualenvs)
When you invoke "python" in your console it launches the default Python interpreter (in your case Python 2.7.10). Looks like in PyCharm you selected different interpreter and installed packages on it. Make sure you use the same interpreter in PyCharm (Settings | Project | Project interpreter)
I needed to use plotting features in python 2.7 hence I downloaded and installed matplotlib package (v1.3.1). When I types import pylab in IDLE I got an exception saying dateutils was needed by matplotlib. So I installed that. Then I was told pyparsing was needed so I installed that. Now I am getting the message that numpy is needed
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pylab
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pylab
File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 156, in <module>
from matplotlib.cbook import is_string_like
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 28, in <module>
import numpy as np
ImportError: No module named numpy
Is there a way to know what are all the dependencies that are needed to use pylab so I don't have to download one by one or am I doing something wrong in the installation that is causing so many missing packages?
OK. I just installed numpy and it seemed to now import pylab correctly. So looks like this was the last package needed. Just is case anyone has an issue like this I am listing which packages I had to download to get to this:
matplotlib
dateutils
pyparsing
numpy
Installing #1, 3, and 4 was fairly straightforward as these had installers which found the installed python version and accordingly installed in correct location. However, for #2 I had to you download the tar.gz file. The unzip and untar it and manually copy the dateutil folder from the unpackaged folder into the python installation (also see How to install python-dateutil on Windows?)