When I am running
from docx import Document
I am getting error as
ImportError: cannot import name Document
I am working on Python 2.7.
It looks like you have installed only docx, but I tried with this and worked for me:
pip uninstall docx
pip install python-docx
This way you will be using the newest version of the library, hope you find it useful.
I am trying to install numpy on openshift so that my django website can access it. I tried to install it by calling pip install numpy in the pod terminal. This seemed to install but when I tried to import numpy in my code it gave ImportError: No module named numpy
If you are using the OpenShift S2I builder for Python, you would be pointing it at your repository with your application source code. That repo should have a requirements.txt file in it which lists the names of the Python packages you want installed. So create that file and add numpy to it and then trigger a new build and deployment of your application.
If you are not using the Python S2I builder, you need to explain how you are running your application under OpenShift.
I try to run python script with from fast import FAST and I get an error:
ImportError: No module named fast
I don't know what is this module for and where to get it. Does somebody know?
In case of unknown modules, Python Package Index homepage is main source of information. Looks like you're missing package for software testing
Assuming you have pip installer (maybe How to install pip on windows will be useful, if you're on windows) all you have to do is:
pip install fast
which downloads package with it's dependencies and installs it into your local python package library.
there!
I am trying to run an imported app on my Ubuntu. But the error message displayed on the screen says No module named phonenumbers
So I tried to install it, by:
sudo easy_install phonenumbers
But again, it throws error, and says ImportError: No module named shortdata
Then I tried to run
sudo easy_install shortdata
This time it gives me:
error: Could not find suitable distribution for Requirement.parse('shortdata')
I cannot figure out how to install 'shortdata'.
What can I do, to make 'phonenumbers' installed?
The issue happening because the module 'shortdata' is get missing while installation. You can correct the issue by installing from source and manually copy the module 'shortdata'.
1)Download source from https://github.com/daviddrysdale/python-phonenumbers
2)Install phonenumbers using setup.py (python setup.py install)
3)Manually copy folder 'shortdata' from python-phonenumbers-dev/python/phonenumbers in source to your installed location(python2.7/site-packages/phonenumbers-5.7b1-py2.7.egg/phonenumbers)
I'm deploying something that has been running on my local and realized when I deployed that the module I was using wasn't installed on Heroku, thus I was getting an error like this:
...
from PIL import Image
ImportError: No module named PIL
I've tried:
heroku run pip install PIL
but I'm getting this:
ImportError: No module named setuptools.command
edit
So, I went to the heroku setup and mimicked the steps to install django and postgres. Essentially, I activated the environment and then ran
pip install PIL
This seemed to be doing the trick, I got a lot of readout and then it ended with a confirmation that PIL had been installed. But then again, it said it couldn't find PIL when I ran the new file.
Every command you run on Heroku is run in an isolated and ephemeral environment — any changes you make during heroku run are thrown away immediately when the processes completes.
To make PIL available to your application, you need to add it to requirements.txt instead.
Sometimes PIL package is added in your path but it's somewhere else than in site-packages. In this case you will be able to just import Image.
To make sure try something like this:
>>> import sys
>>> sys.path
[(...), '/usr/lib/python2.7/dist-packages/PIL', (...)]
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
>>> import Image
>>> Image
<module 'Image' from '/usr/lib/python2.7/dist-packages/PIL/Image.pyc'>
In my applications I use code like this:
try:
import Image, ImageDraw, ImageFont
except:
from PIL import Image, ImageDraw, ImageFont
Are you sure you have followed http://devcenter.heroku.com/articles/django#prerequisites and your virtualenv is loaded?
BTW, I recommend using Pillow instead of PIL.
Introduction
The fork author's goal is to foster packaging improvements via:
Publicized development and solicitation of community support.
Exploration of packaging problems within the fork, most noticably via
adding setuptools support but also via clean up & refactoring of
packaging code. Why a fork?
PIL is currently not setuptools compatible. Please see
http://mail.python.org/pipermail/image-sig/2010-August/006480.html for
a more detailed explanation. Also, PIL's current release/maintenance
schedule is not compatible with the various & frequent packaging
issues that have occured.
Even i was facing the same issue, I spent quite a lot of time.
I tried this
heroku run pip install PIL --app=your-app
error:
Running `pip install PIL` attached to terminal... up, run.1983
Downloading/unpacking PIL
Could not find any downloads that satisfy the requirement PIL
Some externally hosted files were ignored (use --allow-external PIL to allow).
Cleaning up...
No distributions at all found for PIL
Storing debug log for failure in /app/.pip/pip.log
But this helps like a charm :)
heroku run pip install Pillow --app=your-app