Python Azure ImportError 外部未找到模块
Python external on Azure ImportError No Module Found
如果我在本地 运行 我的代码使用 python main.py,则此错误会在本地发生。如果我 运行 它与 python3 main.py,它会按预期工作。我怀疑我的 azure 应用程序服务 运行 不是 python 的正确版本,但是,它设置为 python 3.4
StdErr:
2018-06-30 19:47:13.785205: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 120, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 89, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "main.app" could not be imported: Traceback (most recent call last):
File ".\ptvs_virtualenv_proxy.py", line 73, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\home\site\wwwroot\main.py", line 2, in <module>
from newspaper import Article
ImportError: No module named 'newspaper'
更新
所以我去了 kudo 的调试控制台,我 运行 python
-m pip install --upgrade -r d:\home\site\wwwroot\requirements.txt
.
这里是错误
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt
其中一个要求是 Pillow,它需要 libxml2 和 libxslt。我试过使用轮子,但没有成功。
更新二
我尝试安装 virtualenv,因为它不存在并且我收到权限错误。
更新三
我运行这个命令
D:\home\python364x64>python -m pip install newspaper3k
我在本地测试了所有内容,它运行良好。我在下面推送并收到此错误。
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\app.py", line 8, in <module>
from newspaper import Article
File "D:\home\python364x64\lib\site-packages\newspaper\__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "D:\home\python364x64\lib\site-packages\newspaper\api.py", line 12, in <module>
import feedparser
File "D:\home\python364x64\lib\site-packages\feedparser.py", line 316
raise KeyError, "object doesn't have key 'category'"
^
SyntaxError: invalid syntax
StdOut:
StdErr:
根据我的经验,我们无权修改 D:\home
环境。
所以,最好使用 python 扩展名。请按照这种情况下的步骤操作: 并使用命令 python -m pip install newspaper
在 python 扩展中安装其他软件包。
请确保您要安装的软件包必须与 python 扩展程序的版本相匹配。否则会报错如下。
希望对你有帮助。
如果我在本地 运行 我的代码使用 python main.py,则此错误会在本地发生。如果我 运行 它与 python3 main.py,它会按预期工作。我怀疑我的 azure 应用程序服务 运行 不是 python 的正确版本,但是,它设置为 python 3.4
StdErr:
2018-06-30 19:47:13.785205: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 120, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 89, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "main.app" could not be imported: Traceback (most recent call last):
File ".\ptvs_virtualenv_proxy.py", line 73, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\home\site\wwwroot\main.py", line 2, in <module>
from newspaper import Article
ImportError: No module named 'newspaper'
更新
所以我去了 kudo 的调试控制台,我 运行 python
-m pip install --upgrade -r d:\home\site\wwwroot\requirements.txt
.
这里是错误
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt
其中一个要求是 Pillow,它需要 libxml2 和 libxslt。我试过使用轮子,但没有成功。
更新二 我尝试安装 virtualenv,因为它不存在并且我收到权限错误。
更新三 我运行这个命令
D:\home\python364x64>python -m pip install newspaper3k
我在本地测试了所有内容,它运行良好。我在下面推送并收到此错误。
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\app.py", line 8, in <module>
from newspaper import Article
File "D:\home\python364x64\lib\site-packages\newspaper\__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "D:\home\python364x64\lib\site-packages\newspaper\api.py", line 12, in <module>
import feedparser
File "D:\home\python364x64\lib\site-packages\feedparser.py", line 316
raise KeyError, "object doesn't have key 'category'"
^
SyntaxError: invalid syntax
StdOut:
StdErr:
根据我的经验,我们无权修改 D:\home
环境。
所以,最好使用 python 扩展名。请按照这种情况下的步骤操作:python -m pip install newspaper
在 python 扩展中安装其他软件包。
请确保您要安装的软件包必须与 python 扩展程序的版本相匹配。否则会报错如下。
希望对你有帮助。