I work on GAE project in PyDev
I'd like to use the PDFminer library in order to convert a pdf file to a text file.
My problem is when i run the application it dosn't work and it displays this error message :
ImportError: No module named pdfminer.converter
I tested the same code in a normale python project and it works fine.
I used the same code in python console and it works too
I add the pdfminer folder to the python interpreter, i removed the interpreter and i add it again but i have always the same error.
Really i don't what i have to do, can anybody help me please ?
The problem comes from the fact that the PDFMiner is a third party library i copied the PDFMiner's files into the project and i works fine GAE don't import lib if isn't a pure python even if it exits in PYTHONPATH I found the solution in this post: Google App Engine "no module named requests" PyDev
Related
I am trying to add Google Cloud Storage functionality to a Python GAE app that is already running with significant functionality. I work entirely within PyCharm on my development computer, which is a Mac running OS X 10.9.5.
I have created a new Python module that contains this statement:
import cloudstorage as gcs
as shown in the sample code at https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/getstarted
When I first added that line, PyCharm said "No module named cloudstorage" in the editor.
I then followed both the "pip" and the "svn" instructions at https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/download
to download the GCS Client Library.
In trying to follow those instructions, taking into account my prior experience with this programming environment, I actually tried using "pip" three times:
Once without the "-t" option, since I've never needed that option with "pip" before
Once using the "-t" option to specify my application directory's "lib" subdirectory
Once using:
pip install GoogleAppEngineCloudStorageClient -t /Applications/GoogleAppEngineLauncher.app//Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib, since I wasn't sure what the instructions meant by "<your_app_directory/lib>"
As mentioned, I also executed the "svn" command. Then, as mentioned in install python google cloud storage client on Ubuntu 14.04, I ran "cd gcs-client/src" and "sudo python setup.py install". I ran these commands in my user root directory.
After each of those successful but different installations of the GCS Client Library, I looked at the PyCharm editor window for my module, and it always had the same "No module named cloudstorage" error. But as an experiment, I would also try restarting PyCharm, and also try running my app.
At some point, the editor window stopped showing the error. It was not immediately after one of those steps above, but after I would go away to read various webpages and then come back to look at the error again. I don't know which of the installations was the one that got rid of the error message in the PyCharm editor.
In any case, whenever I try to run the app (again, inside PyCharm), I always get the runtime error "ImportError: No module named cloudstorage" on the same import statement.
The Run/Debug Configuration page for this app has both "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" checked.
Of course the main help I want is how to get past the "No module named cloudstorage" runtime error, even though the import statement no longer shows an error.
I think I also have as many as three spurious versions of the GCS Client Library. I'm much more concerned with getting past "Module not found", since it's a show-stopper, but if you have any idea how I can delete the spurious versions so that they're not just lying around, I'd be most grateful for that help as well.
If the "cloudstorage" directory is at <app>/lib/cloudstorage, then the import statement has to specify "lib":
import lib.cloudstorage
In my case, it's:
import lib.cloudstorage as gcs
By the way, the <app>/lib/GoogleAppEngineCloudStorageClient-1.9.5.0-py2.7.egg-info directory does not seem to be needed and can be deleted.
Actually, you also need to
touch __init__.py
in the lib directory. This will make the cloudstorage module visible to the "import lib.cloudstorage" command.
Dear Google: The distributions should include this file (or the procedure should account for it), and the demo script should be changed to reflect the expected usage. But more importantly why are you distributing/PROLIFERATING library code like this??!!! Why is this not distributed via gcloud? How am I ever going to pick up a patch for this library?
The accepted answer's solution
import lib.module_name
definitely can solve the problem. But I don't like add lib in front of every single module and happened to see how Google suggest import third party libs like this.
appengine will automatically run a file called appengine_config.py. So you can create such a file and put
from google.appengine.ext import vendor
vendor.add('lib')
inside that file. This will help you tell appengine to find dependencies in that folder, so you can simply write
import cloudstorage as gcs
I solve the missing module issue by adding the following to my main application file (main.py):
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
I think this is the way Guido intended. Now my code simply says import cloudstorage as gcs. None of the lib.cloudstorage or lib/__init__.py business.
From
https://stackoverflow.com/a/37645984/1740008
I am new to GAE. I wish to use the QuantLib python library (SWIG) as a module inside google app engine. I was following this blog post to set up QuantLib-SWIG on Ubuntu. http://blog.quantess.net/2012/09/26/quantlib-get-it-working-on-ubuntu/
I have compiled the modules for python using make -c Python after installing the required boost c++ libraries as mentioned in the post.
I've copied the QuantLib folder to my app folder. The QunatLib folder contains the following files:
__init__.py
__init__.pyc
QuantLib.py
QuantLib.pyc
_QuantLib.so*
This is my app directory structure:
app.yaml
index.py
QuantLib/
However, when I do an
import QunatLib
in the index.py in my app folder, I get the following error:
<type 'exceptions.ImportError'>: No module named _QuantLib
args = ('No module named _QuantLib',)
message = 'No module named _QuantLib'
I also get this is dev_appserver logs:
ImportError: No module named _QuantLib
_QuantLib is a .so file. Is there a way I can fix this problem? Or any other way to use QuantLib libraries for GAE?
Thanks.
No.
There are a limited number of 3rd party libraries that are not pure python. You cannot add your own non pure python libraries to appengine runtime.
Here is the current list of included 3rd party libs https://developers.google.com/appengine/docs/python/tools/libraries27
You can add any pure python libraries in your own code base.
I downloaded and installed requests library for Python 2.7. Using the shell I can make "import requests" and actually use it without problems.
Thing is that when running Google App Engine it can't find it and prompts the error:
ImportError: No module named requests
I'm using PyDev-Eclipse as IDE for my project and tried adding the path (/usr/local/lib/python2.7/dist-packages/requests) both in
Project > properties > PyDev - PYTHONPATH > External Libraries
and in
Window > preferences > Pydev -Interpreter > Libraries
and none worked! Still having the same issue when trying to run my GAE app
Anyone could help?
Thanks!
Any 3rd party lib you use must be physically included in your project and deployed to appengine. This means it is not sufficient to just install with easy_install or pip
See the docs https://developers.google.com/appengine/docs/python/runtime#Pure_Python
I don't know why, but when I launch my application I suddenly always receive the following error (that before never appeared):
java.lang.NoSuchMethodError: com.google.gdata.client.authn.oauth.GoogleOAuthParameters.setOAuthType(Lcom/google/gdata/client/authn/oauth/OAuthParameters$OAuthType;)
The line of code generating the error is:
oauthParameters.setOAuthType(OAuthParameters.OAuthType.TWO_LEGGED_OAUTH);
That error wasn't appeared before, always in eclipse there wasn't an error and all was working fine.
I've never changed library. It seems that when I deploy to app-engine it doesn't upload the jar with that class?
Since you're only seeing this issue when you deploy, it sounds like you've included the gdata-java-client jars in a location so that they are visible to your local Java runtime, but are not sent to the App Engine server upon deployment.
The easiest way to resolve this is to include the gdata-java-client and its dependencies in the war/WEB-INF/lib directory of your application, and to reference those jars in your Java build path within Eclipse.
I've created Google App Engine project in Java using Eclipse following the book Beginning Java Google App Engine
Before I bought this book I had created projects with unchecked option 'Use Google Web Toolkit' but for this project I checked it (following the book)
Eclipse generated several files for me and I run my applications, copy link to Web Browser (http://localhost:8888) and it gives me an error:
GWT module name_of_my_project may need to be (re)complied
I work on Ubuntu 10.04 (I was testing my application using Firefox and Chromium) and I was trying run my application on Windows XP (using the same Web Browsers) with the same effect (just one difference - Google Chrome made me install Web Toolkit...so I did it but it still gives the same error)
Thanks in advance :)
I get the same error message at unexpected times using development on IntelliJ with Chrome. The message still appears when I stop and start development mode. The problem is fixed after I delete the compiled files (class files, js files) in the out folder. On eclipse, you can try deleting files and folders generated in the war folder (delete the folder that has the project name, if it exists, and the classes folder under /war/WEB-INF/classes). Hope this helps.
Check in your "Java Build Path" if you have the correct Default output folder (something like /target/project-name/WEB-INF/classes).
In Eclipse, do a "Clean Build".
Click on the google blue button in the Eclipse menu and select "GWT Compile Project..."
Make sure the GWT plugin is compiling your project by checking the compiler output. The GWT compiler outputs lots of things, for example you will always see something like "Compiling 6 permutations.... Compiling permutation 0..."
If you still have problems, try this page on setting up Eclipse with GWT: http://code.google.com/webtoolkit/usingeclipse.html
Thanks for your comments and suggestions. I re-installed Eclipse on Ubuntu and I installed plugin one more time and it works :)
So, be careful which version of Eclipse you use - Eclipse 3.4 has problem with GWT.