I'm trying to create a function which reads pptx files. The only module I found is python-pptx. But unfortunately, it raises errors.
There were some problems with installing Pillow when I did: pip install python-pptx so I installed it easy_install Pillow which seems to be working. Then I installed python-pptx. The problem is that when I execute the function it still raises error:
Traceback (most recent call last):
File "C:/Users/Milano/Desktop/Projekty/FS Dropbox/Dropbox/word_counter.py", line 38, in <module>
print get_pptx_word_count('pptx.pptx')
File "C:/Users/Milano/Desktop/Projekty/FS Dropbox/Dropbox/word_counter.py", line 15, in get_pptx_word_count
from pptx import Presentation
File "C:\Users\Milano\Desktop\Projekty\venvs\sfl_venv\lib\site-packages\pptx\__init__.py", line 15, in <module>
from pptx.api import Presentation # noqa
File "C:\Users\Milano\Desktop\Projekty\venvs\sfl_venv\lib\site-packages\pptx\api.py", line 17, in <module>
from .package import Package
File "C:\Users\Milano\Desktop\Projekty\venvs\sfl_venv\lib\site-packages\pptx\package.py", line 16, in <module>
from .parts.image import Image, ImagePart
File "C:\Users\Milano\Desktop\Projekty\venvs\sfl_venv\lib\site-packages\pptx\parts\image.py", line 13, in <module>
import Image as PIL_Image
ImportError: No module named Image
What should I do? I'm on virtualenv. Tried to uninstall Pillow and install PIL but it didn't find anything.
pillow moves all the PIL modules to the PIL package. You will need to modify the import to PIL.Image.
Related
I have a project where I'll use the face_recognition library to recognise faces in Images. I tried the following code to make sure if the library is working:
from PIL import Image
import numpy as np
import face_recognition
obama_image = face_recognition.load_image_file("obama.jpg")
But I get the following error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
import face_recognition
File "C:\Users\علي\AppData\Roaming\Python\Python38\site-packages\face_recognition\__init__.py", line 7, in <module>
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "C:\Users\علي\AppData\Roaming\Python\Python38\site-packages\face_recognition\api.py", line 20, in <module>
pose_predictor_68_point = dlib.shape_predictor(predictor_68_point_model)
RuntimeError: Unable to open C:\Users\علي\AppData\Roaming\Python\Python38\site-packages\face_recognition_models\models\shape_predictor_68_face_landmarks.dat
I tried some sulotions that I found but nothing worked.
I downloaded dlib library in the proper way.
I redownloaded the file shape_predictor_68_face_landmarks.dat.
I tried to copy the file to the directory of my python file, but still not working.
Thanks in advance
I'm using terminal on mac, and anytime I attempt to use pip, I get the following error message telling me that it cannot find a module named zlib:
$ pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.6/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 36, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
I've read several SO posts with the same error message, and have tried their solutions, including attempting to install zlib using homebrew, which fails, and updating my Xcode developer tools. I also installed pip earlier using python get-pip.py, and it said it installed successfully.
The reason I need pip is to install a package for use on python 2.7, but doing $ pip install "package-name" produces the same error as above. I have both Python 2 and 3 installed on my machine, if that helps. I'm kind of new to pip and using the command line in general, and I'm super confused; if anyone could help me out I'd really appreciate it.
This is the OP. I was able to fix the issue, and wanted to post my solution here in case it would help others.
Essentially I believe it occurred because Python2 is default on my machine, but pip is by default pointing to resources pertaining to Python3, or something like that. Doing pip2 --version instead provided the expected response.
Hi, is there a solution for this error code ?
Traceback (most recent call last):
File "./weevely.py", line 2, in <module>
from core.terminal import Terminal
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/terminal.py", line 6, in <module>
from core.module import Status
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/module.py", line 14, in <module>
from core.vectorlist import VectorList
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectorlist.py", line 15, in <module>
from core.vectors import Os
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectors.py", line 11, in <module>
from mako.template import Template
ImportError: No module named mako.template
Thanks.
The answer is pretty self explainatory and with a google search you could have solved everything in seconds.
Here you have a how to install pip if you don`t have it: How do I install pip on macOS or OS X?
After this type in the terminal:
pip install Mako
as stated in the official website: http://www.makotemplates.org/download.html
If this doesn`t work you can manually download the Mako package here:
https://pypi.python.org/pypi/Mako/
Please, also read this carefully:
https://stackoverflow.com/help/how-to-ask
I want to do some image processing and I encountered a problem. Importing the pillow module doesn't seem to work. I found a simple script here to check what packages are installed and I found it, but importing it doesn't seem to work.
Here's the code I'm trying to run:
import pip
installed_packages = pip.get_installed_distributions()
installed_pillow_packages = [
"%s==%s" % (i.key, i.version)
for i in installed_packages
if "pil" in i.key.lower()
]
print(installed_pillow_packages)
import pillow
And here's the result:
runfile('C:/Users/Augustas/.spyder2/temp.py', wdir=r'C:/Users/Augustas/.spyder2')
['pillow==2.6.1']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 601, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 66, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/Augustas/.spyder2/temp.py", line 7, in <module>
import pillow
ImportError: No module named pillow
I'm running this on Windows 8.1 using Spyder and Python 2.7.9.
You are importing incorrectly. Try using:
import PIL
or
from PIL import Image
PIL, i.e., Python Imaging Library is no longer maintained, Pillow is used instead. To maintain backwards compatibility, the PIL module name is used in imports.
In fact, Pillow is installed under name "PIL", so:
import PIL as pillow
from PIL import Image
...
Look this:
Checkout the doc:
http://pillow.readthedocs.org/handbook/tutorial.html
You must import it like that:
import PIL
I use Python 3.2.3
Tonight I tried to install requests from http://docs.python-requests.org/en/latest/ by pip and easy_install, but it doesn't work. I have error when trying to import it. So I decided to use standard library urllib.request and see this error again
That is the traceback:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\__init__.py", line 52, in <module>
from . import utils
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\utils.py", line 12, in <module>
import cgi
File "E:\Python32\lib\cgi.py", line 38, in <module>
from email.parser import FeedParser
File "E:\Python32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "E:\Python32\lib\email\feedparser.py", line 27, in <module>
from email import message
File "E:\Python32\lib\email\message.py", line 17, in <module>
from email import utils
File "E:\Python32\lib\email\utils.py", line 28, in <module>
import socket
File "E:\Python32\lib\socket.py", line 46, in <module>
import _socket
ImportError: Module use of python26.dll conflicts with this version of Python.
So how can I fix this?
UPD: Solved. It was bug in SublimeREPL, reinstalled that package.
I had a similar problem when I was using PythonXY. The Spyder was not loading and it turns out another software OpenCAD had installed Python2.6 version and that was not letting my Python27.dll to not work. After uninstalling OpenCAD, I was able to run the software.
I was able to troubleshoot by first searching for python26.dll and found that this file was located in the OpenCAD folder location and that made me realize that this software was causing the issue.