我正在嘗試使用feed-parser模塊來處理此項目。當我將文件上傳到App Engine並運行該腳本時,它返回了錯誤,即沒有名爲feed-parser的模塊。將Python模塊添加到Google App Engine項目
所以我想知道是否以及如何在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
- 發展1:
所以我試着在我創建的lib目錄下安裝模塊(在這個例子失敗我--prefix = ..忘了/ lib。)。我在shell中顯示PYTHONERROR。我已經做了一些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.
然後,我嘗試用「點子」的命令,但後來我得到這個:
can't open file 'pip': [Errno 2] No such file or directory
據我已閱讀「點子」應該是與Python 2.7和最多安裝的默認程序。所以爲了確保我安裝了python3.5並運行它,仍然得到相同的錯誤。我打這個既蟒蛇:
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')
其部署和IM仍然得到同樣的錯誤如上沒有模塊名爲feeedparser。
道歉,如果我做了一些愚蠢的錯誤,我仍然在學習過程中。
解釋如何添加第三方模塊
您應用中的feedparser文件在哪裏?另外,你可以發佈你的appengine_config.py文件的內容,如果你有嗎? – snakecharmerb
@snakecharmerb它不在我的應用程序文件中,它自動在我的系統上安裝模塊。我應該找到一種方法將它安裝在aap根文件中嗎?並且不,我還沒有appengine_config.py文件。正如我的研究,雖然我是你處理模塊的文件? – Kevin