使用dev_appserver.py當我運行dev_appserver.py .
(含該app.py
的目錄),而在virtualenv中使用Python 2.7.12是,我得到這個錯誤並輸出:導入錯誤,而在virtualenv中
(.venv)$ dev_appserver.py .
INFO 2017-02-21 18:54:47,250 devappserver2.py:764] Skipping SDK update check.
INFO 2017-02-21 18:54:47,273 api_server.py:268] Starting API server at: http://localhost:35473
INFO 2017-02-21 18:54:47,276 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO 2017-02-21 18:54:47,276 admin_server.py:116] Starting admin server at: http://localhost:8000
Traceback (most recent call last):
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 101, in <module>
_run_file(__file__, globals())
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 97, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime.py", line 185, in <module>
main()
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime.py", line 165, in main
sandbox.enable_sandbox(config)
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 198, in enable_sandbox
__import__('%s.threading' % dist27.__name__)
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/threading.py", line 11, in <module>
import warnings
File "/opt/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 1001, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named warnings
廠很好,當我不在virtualenv。根據我的理解,warnings
模塊是Python標準庫的一部分,所以不知道該怎麼做。運行pip install warnings
沒有幫助。
如何讓dev_appserver.py在virtualenv中運行?
在你的'.venv/lib/python2.7'目錄中,是否有'warnings.py'的符號鏈接。 –
是的,它在那裏。 – haeger
@ haeger你能解決這個問題嗎?我也堅持同樣的問題 –