0

I'm trying to use the feed-parser module for this project im working on. When I upload the files to App Engine and I run the script it comes back with the error that the there is no module named feed-parser.

So I'm wondering if and how can I install this module on App Engine, so that I can fix this error and use RSS.

Error:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~vlis-mannipulus-bot/1.391465315184045822/main.py", line 7, in <module>
    import feedparser
ImportError: No module named feed parser

  • Development 1:

So I've tried installing the module in the lib directory i created(in this fail example i forgot the /lib at the --prefix=..). And i get PYTHONERROR as is shown in the shell. Ive done some research on python paths and the solutions i tried didn't work for me.

kevins-MacBook-Pro-2:~ KevinH$ cd /Users/KevinH/Downloads/feedparser   -5.2.1 
kevins-MacBook-Pro-2:feedparser-5.2.1 KevinH$ sudo python setup.py     install --prefix=/Users/KevinH/Documents/Thalia\ VMbot/Thalia-VMbot/
Password:
running install
Checking .pth file support in /Users/KevinH/Documents/Thalia     VMbot/Thalia-VMbot//lib/python2.7/site-packages/
/usr/bin/python -E -c pass
TEST FAILED: /Users/KevinH/Documents/Thalia VMbot/Thalia-    VMbot//lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/Users/KevinH/Documents/Thalia VMbot/Thalia-VMbot//lib/python2.7/site-   packages/

and your PYTHONPATH environment variable currently contains:

''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
variable.  (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:

https://pythonhosted.org/setuptools/easy_install.html#custom-  installation-locations

Please make the appropriate changes for your system and try again.

Then i tried with the "pip" command but then i get this:

can't open file 'pip': [Errno 2] No such file or directory

According to what I have read "pip" should be a default program installed with python 2.7 and up. So to be sure i did install python3.5 and ran it with that and still get the same error. I typed this with both pythons:

kevins-MacBook-Pro-2:feedparser KevinH$ python3 pip -m install feedparse

--

Not sure if this would work, but via terminal i went to the default directory where feed parser has been installed on my system and copied it to the lib directory i made. Then I've created the config file with the following:

from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')

Deployed it and im still getting the same error as above no module named feeedparser.

Apologies if im doing something stupidly wrong, im still in the learning process.

Kevin
  • 37
  • 10
  • Where are the feedparser files in your app? Also, can you post the contents of your appengine_config.py file, if you have one? – snakecharmerb Mar 18 '16 at 18:08
  • @snakecharmerb It is not in my app files, it automatically installed the module on my system. I should find a way to install it in the aap root files shouldn't I ? And no i don't have an appengine_config.py file yet. As my research though me that is the file you handle modules with ? – Kevin Mar 18 '16 at 18:21

1 Answers1

0

The App Engine documentation that explains how to add third party modules is here

In summary, you will need to add a folder, usually named 'lib', to the top level off your app, and then install feedparser into that folder using the commands described in the documentation. You will also need to create an appengine_config.py file as descibed in the documentation.

Note that not all third party packages can be uploaded to App Engine - those with C extensions are forbidden. Feedparser looks OK to me though.

EDIT: further comments based on edit "development1" to the question.

Your appengine_config.py looks good.

You "lib" folder should be your application folder, that is the same folder as your app.yaml and appengine_config.py files.

You need to install the feedparser package into the lib folder. The Google docs recommend that you do this by running the command

pip install -t lib feedparser

This command will install the feedparser package into your lib folder.

You need to install and run a version of pip that works with Python2.x - the Python3 version will create a version of feedparser that only runs under Python3.

If you can't install a pip for Python2 this question might provide the right solution, otherwise I'd suggest you ask a separate question about how to install feedparser into a custom install directory on a Mac.I don't have a Mac so I can't help with this.

Once you have feedparser installed in your lib folder, verify that your app works locally; in particular verify that it's using your lib/feedparser installation: try logging feedparser.__file__ after importing feedparser to check the location of the file being imported.

Once everything is working locally you should be able to upload to GAE.

So in summary, your appengine_config.py looks good, but you need to make sure that the right version of feedparser is installed into the lib folder in your app folder before uploading to App Engine.

Community
  • 1
  • 1
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
  • im getting this error when im trying to install it in a directory that isn't default: ` You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was ` – Kevin Mar 18 '16 at 20:18
  • i have managed to get the feed parser.egg file in the lib directory and added the appegine config file but im still getting the same error X__X should i edit the first question with these developments for u to see ? – Kevin Mar 18 '16 at 22:38
  • Yes please, copy and paste the commands that you enter and the output. – snakecharmerb Mar 19 '16 at 07:27
  • Ok i have edited the the questions under "development 1". I am grateful that u are taking time to help me :) – Kevin Mar 19 '16 at 12:06
  • Yes! I have managed to install pip and install the module in the lib folder. I deployed to GAE and didn't get the error "no module". Thank you very much sir. – Kevin Mar 19 '16 at 19:57