2
votes

I'm new in python, I've it installed in C:\ & I just started with GAE's Hello World app, I downloaded PyImgur have it installed via cmd python setup.py install but I get a error as ImportError: No module named pyimgur in the gae logs. So how do I import it in my main.py script?

app.yaml

application: engineapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

main.py

import webapp2
import pyimgur

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello world!')

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)

THIS IS THE GAE ERROR

INFO 2013-07-08 08:15:47,197 server.py:593] default: "GET / HTTP/1.1" 500 - INFO 2013-07-08 08:28:22,289 api_server.py:509] Applying all pending transactions and saving the datastore INFO 2013-07-08 08:28:22,289 api_server.py:512] Saving search indexes 2013-07-08 08:28:22 (Process exited with code 0)

2013-07-08 08:28:23 Running command: "['C:\Python27\pythonw.exe', 'C:\Program Files (x86)\Google\google_appengine\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', u'C:\fb-app\engineapp']" INFO 2013-07-08 08:28:29,868 devappserver2.py:528] Skipping SDK update check. INFO 2013-07-08 08:28:29,982 api_server.py:138] Starting API server at: http://localhost:59917 INFO 2013-07-08 08:28:29,989 dispatcher.py:164] Starting server "default" running at: http://localhost:8080 INFO 2013-07-08 08:28:29,993 admin_server.py:117] Starting admin server at: http://localhost:8000

ERROR    2013-07-08 15:28:33,897 wsgi.py:219] 

Traceback (most recent call last):

  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 196, in Handle

    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())

  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 255, in _LoadHandler

    handler = __import__(path[0])

  File "C:\fb-app\engineapp\main.py", line 18, in <module>

    import pyimgur

ImportError: No module named pyimgur

INFO     2013-07-08 08:28:33,907 server.py:593] default: "GET / HTTP/1.1" 500 -
2
UPADTE A new version v0.4.2 was released & this fixed the issue, of pyimgur import, after the updates I was able to import the module pyimgur in my gae app as well as in python cmd. (thanks for all your input I did include the module files in my app directory as well, it fixed it!) - Simon K Bhatta4ya

2 Answers

1
votes

For modules on the Google App Engine servers, other than those in official third party libraries you have to upload them with your application code.

For local dev_appserver, they have to reside in your PYTHONPATH.

The safe way to resolve both is to place the desired module in your application directory, as the dev_appserver extends PYTHONPATH by it.

0
votes

You need to include the pyImgur source code in your app. Include the module in your app directory (the directory where your app.yaml lives), or one of its subdirectory.