0

I am on Mac OS and developing for google cloud platform. I have created vitualenv - virtualenv xyz. I activated using - source xyz/bin/activate Then, I installed the pkg I needed - pip install python-dateutil When I do pip list, I do see the python-dateutil is there But 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

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?

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.

BI Architect
  • 265
  • 2
  • 4
  • 10

1 Answers1

1

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

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
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • So if I am using standard environment, how do I have a fresh environment with no packages installed, each time I start a new project. Basically same thing as virtualenv. – BI Architect Aug 25 '17 at 16:11
  • I'm sorry, I'm not sure I get your question. In stdenv you always start with the sandbox-provided packages (and on the your local system by the SDK). Anything extra needs to be added to your app. – Dan Cornilescu Aug 25 '17 at 16:16
  • In my dev environment, lets say i am working on project 1 and did `pip install python-dateutil`. I am guessing this gets installed in my global env. And I switch to project 2 (still in my dev) and it will have access to global packages but I don't want to refer python-dateutil in project 2. How do I keep separate copies of python packages for each project. – BI Architect Aug 25 '17 at 16:29
  • 1
    What you install in the venv is irellevant for standard apps. Only what's installed in each app's `lib` dir is relevant (which is uploaded to GAE together with your app). So you only install in each app's dir what that particular app needs. – Dan Cornilescu Aug 25 '17 at 16:53