问题描述
我在Mac OS上并且正在为Google Cloud Platform开发.我创建了vitualenv-virtualenv xyz
.我使用-源xyz/bin/activate激活了然后,我安装了所需的pkg-pip install python-dateutil
当我执行pip list
时,我确实看到了python-dateutil
但是,当我使用dev_appserver.py .
运行我的服务并尝试发出发布请求时.我得到ImportError: No module named dateutil.parser
I am on Mac OS and developing for google cloud platform.I have created vitualenv - virtualenv xyz
.I activated using - source xyz/bin/activateThen, I installed the pkg I needed - pip install python-dateutil
When I do pip list
, I do see the python-dateutil
is thereBut when i run my service using dev_appserver.py .
and try to make a post request. I get the ImportError: No module named dateutil.parser
问题:在我的appengine_config.py
中,我有vendor.add('lib')
,但是软件包安装在my_project-> xyz -> lib -> python2.7 -> site-packages -> dateutil
下.我的应用程序如何知道在哪里寻找软件包?
Questions: In my appengine_config.py
, I have vendor.add('lib')
but the packages are installed under my_project-> xyz -> lib -> python2.7 -> site-packages -> dateutil
. How does my app knows where to look for packages?
第二个问题:准备部署到生产环境时,如何部署软件包. pip freeze > requirements.txt
.足以让prod服务器知道要使用哪些软件包.我需要my_project下的lib
文件夹吗?我对如何在virtualenv和生产环境中引用软件包感到困惑.
Second question: When I am ready to deploy to production, how do I deploy the packages. pip freeze > requirements.txt
. Is that enough for prod server to know what packages to use. Do I need lib
folder under my_project? I am confused about how packages get referred in virtualenv and in production.
推荐答案
您正在混合安装标准环境和灵活的环境.相关内容:如何判断Google App Engine文档页面是适用于标准环境还是灵活环境
You're mixing the instructions for installing dependencing for the standard environment with those for the flexible environment. Related: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment
您使用的是dev_appserver.py
,因此我假设您的应用是标准环境,在这种情况下,您需要将库安装到应用中(请注意-t lib
参数),而不是在系统/venv上.假设您从应用程序的目录执行:
You're using dev_appserver.py
so I assume your app is a standard environment one, in which case you need to install the library into your app (note the -t lib
arguments), not on the system/venv. Assuming you execute from your app's dir:
pip install python-dateutil -t lib
这篇关于python virtualenv没有模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!