As part of migrating from ndb
to cloud-ndb
with GAE Python 2, you need to add the following to appengine_config.py
:
import pkg_resources
from google.appengine.ext import vendor
vendor.add('lib')
pkg_resources.working_set.add_entry('lib')
When running locally with dev_appserver.py
, I get an error that pkg_resources
can't be found.
How do I fix this?
I found out that you don't need pkg_resources
when running locally with dev_appserver.py
. It is only needed for deployment.
Although I couldn't fix the problem, a good workaround is to update appengine_config.py
to this:
from google.appengine.ext import vendor
vendor.add('lib')
try:
import pkg_resources
pkg_resources.working_set.add_entry('lib')
except ImportError:
pass
With this modification, it works both locally and when deployed.
As part of migrating from ndb to cloud-ndb with GAE Python 2, you need to add the following to appengine_config.py:
Was this in the docs somewhere? I'm curious what lead you to that conclusion.
I encountered a weird error with google-cloud-storage
a while back on both localhost and remote
DistributionNotFound: The 'google-cloud-storage' distribution was not found and is required by the application
It seemed that I had pkg_resources
in multiple places and that I needed the pkg_resources
in my lib
folder to be the one being loaded. I think that the google-cloud-xxxxxxx libs need pkg_resources
to be in the same directory with them in order for them to work. (printing pkg_resources.__file__
shows you which pkg_resources is being picked up).
The fix for me was to do import pkg_resources
& reload(pkg_resources)
after vendor.add('lib')
:
vendor.add('lib')
import pkg_resources
reload(pkg_resources)
I just recently migrated to google-cloud-ndb
and didnt have to make any further changes in regards to pkg_resources
, so now I'm thinking that reload(pkg_resources)
possible saved me from the issue you were facing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.