【发布时间】:2016-03-18 17:53:56
【问题描述】:
我正在尝试将 feed-parser 模块用于我正在进行的这个项目。当我将文件上传到 App Engine 并运行脚本时,它会返回错误,即没有名为 feed-parser 的模块。
所以我想知道是否以及如何在 App Engine 上安装此模块,以便修复此错误并使用 RSS。
错误:
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
- 开发一:
所以我尝试将模块安装在我创建的 lib 目录中(在这个失败示例中,我忘记了 --prefix=.. 处的 /lib)。我得到了 PYTHONERROR,如 shell 所示。我对 python 路径进行了一些研究,但我尝试过的解决方案对我不起作用。
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.
然后我尝试使用“pip”命令,但后来我得到了这个:
can't open file 'pip': [Errno 2] No such file or directory
根据我阅读的内容,“pip”应该是安装了 python 2.7 及更高版本的默认程序。所以为了确保我确实安装了 python3.5 并用它运行它并且仍然得到同样的错误。我用两个 python 都输入了这个:
kevins-MacBook-Pro-2:feedparser KevinH$ python3 pip -m install feedparse
--
不确定这是否可行,但通过终端,我进入了系统上已安装提要解析器的默认目录,并将其复制到我创建的 lib 目录中。然后我使用以下内容创建了配置文件:
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
vendor.add('lib')
部署它,我仍然得到与上面相同的错误,没有名为 feedparser 的模块。
抱歉,如果我做错了愚蠢的事情,我还在学习过程中。
【问题讨论】:
-
您的应用中的 feedparser 文件在哪里?另外,如果您有 appengine_config.py 文件的内容,您可以发布一下吗?
-
@snakecharmerb 它不在我的应用程序文件中,它自动在我的系统上安装了模块。我应该找到一种方法将其安装在 aap 根文件中,不是吗?不,我还没有 appengine_config.py 文件。根据我的研究,您处理模块的文件是什么?