-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't import google.protobuf.timestamp_pb2 from App Engine #1436
Comments
Thanks for reporting and for upgrading! I am curious about a few things:
|
I don't think this shouldn't be necessary anymore, I'm interested to see if that's somehow changed. |
Me too. Thanks for chiming in @jonparrott I was going to ping you. |
I should really write an App Engine test case. |
@SaMnCo can you do a $ python -c 'import google.protobuf; print(google.protobuf.__version__)'
$ python -c 'import gcloud; print(gcloud.__version__)' |
@dhermes I think I've got a similar problem as the reporter of the issue. Perhaps I can help by providing my answers to your questions:
In
Results in:
It's in
|
@kvdb Thanks a lot. I'm wondering now if it may be related to Darth-Vendor and namespace packages not being the best of friends. I need to dig in and reproduce. Can you confirm that's what you used to vendor in your package? |
Darth is part of the SDK ( |
Maybe it's an issue with old versions of
Going to run a test app in |
OK I just confirmed this works in @kvdb Have you tried clearing out |
pip 8.0.2 |
Very strange! Does the |
I was having this error outside App Engine when using an old version of pip and not using the full command to install: pip install --upgrade gcloud I was using |
Outside App Engine means inside Docker, using the |
Thanks for the report @ernestoalejo! @kvdb any thoughts? |
@kvdb Does the I'm closing for now since I can't reproduce and @ernestoalejo answer indicates |
@vsubramani can you give some info on your install: from google import protobuf
print(protobuf.__version__)
print(protobuf.__path__)
print(protobuf.__path__[0])
import os
pb_files = sorted([fi for fi in os.listdir(protobuf.__path__[0])
if fi.endswith('.py')])
print('\n'.join(pb_files)) |
So I had the same issue running In [3]: from gcloud import storage
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-a2d587421817> in <module>()
----> 1 from gcloud import storage
/venv/lib/python2.7/site-packages/gcloud/storage/__init__.py in <module>()
41
42 from gcloud.storage.batch import Batch
---> 43 from gcloud.storage.blob import Blob
44 from gcloud.storage.bucket import Bucket
45 from gcloud.storage.client import Client
/venv/lib/python2.7/site-packages/gcloud/storage/blob.py in <module>()
25 from six.moves.urllib.parse import quote
26
---> 27 from gcloud._helpers import _rfc3339_to_datetime
28 from gcloud.credentials import generate_signed_url
29 from gcloud.exceptions import NotFound
/venv/lib/python2.7/site-packages/gcloud/_helpers.py in <module>()
25 from threading import local as Local
26
---> 27 from google.protobuf import timestamp_pb2
28 import six
29 from six.moves.http_client import HTTPConnection
ImportError: cannot import name timestamp_pb2 Running >>> from google import protobuf
>>> print(protobuf.__version__)
>>> print(protobuf.__path__)
>>> print(protobuf.__path__[0])
>>> import os
>>> pb_files = sorted([fi for fi in os.listdir(protobuf.__path__[0])
if fi.endswith('.py')])
>>> print('\n'.join(pb_files))
__init__.py
descriptor.py
descriptor_database.py
descriptor_pb2.py
descriptor_pool.py
message.py
message_factory.py
proto_builder.py
reflection.py
service.py
service_reflection.py
symbol_database.py
text_encoding.py
text_format.py This was fixed by adding this line into my RUN pip install --upgrade gcloud It looks like you have to force the gcloud installation to upgrade. This was the output while building my docker container. Step 13 : RUN pip install --upgrade gcloud
---> Running in 4670a504231c
Requirement already up-to-date: gcloud in /venv/lib/python2.7/site-packages
Requirement already up-to-date: pyOpenSSL in /venv/lib/python2.7/site-packages (from gcloud)
Requirement already up-to-date: six in /venv/lib/python2.7/site-packages (from gcloud)
Requirement already up-to-date: httplib2>=0.9.1 in /venv/lib/python2.7/site-packages (from gcloud)
Collecting protobuf!=3.0.0.b2.post1,>=3.0.0b2 (from gcloud)
Downloading protobuf-3.0.0b2.post2-py2-none-any.whl (331kB)
Collecting oauth2client>=2.0.1 (from gcloud)
Downloading oauth2client-2.0.2.tar.gz (68kB)
Requirement already up-to-date: googleapis-common-protos in /venv/lib/python2.7/site-packages (from gcloud)
Requirement already up-to-date: cryptography>=1.3 in /venv/lib/python2.7/site-packages (from pyOpenSSL->gcloud)
Requirement already up-to-date: setuptools in /venv/lib/python2.7/site-packages (from protobuf!=3.0.0.b2.post1,>=3.0.0b2->gcloud)
Requirement already up-to-date: pyasn1>=0.1.7 in /venv/lib/python2.7/site-packages (from oauth2client>=2.0.1->gcloud)
Requirement already up-to-date: pyasn1-modules>=0.0.5 in /venv/lib/python2.7/site-packages (from oauth2client>=2.0.1->gcloud)
Collecting rsa>=3.1.4 (from oauth2client>=2.0.1->gcloud)
Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
Collecting enum34 (from cryptography>=1.3->pyOpenSSL->gcloud)
Downloading enum34-1.1.3-py2.py3-none-any.whl (61kB)
Requirement already up-to-date: ipaddress in /venv/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->gcloud)
Requirement already up-to-date: idna>=2.0 in /venv/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->gcloud)
Requirement already up-to-date: cffi>=1.4.1 in /venv/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->gcloud)
Requirement already up-to-date: pycparser in /venv/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->gcloud)
Building wheels for collected packages: oauth2client
Running setup.py bdist_wheel for oauth2client: started
Running setup.py bdist_wheel for oauth2client: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/3f/1b/4b/7d18513fd8ed10976cf4bb881bd0a2b549d4d22d245d0ff1a6
Successfully built oauth2client
Installing collected packages: protobuf, rsa, oauth2client, enum34
Found existing installation: protobuf 3.0.0a3
Uninstalling protobuf-3.0.0a3:
Successfully uninstalled protobuf-3.0.0a3
Found existing installation: rsa 3.3
Uninstalling rsa-3.3:
Successfully uninstalled rsa-3.3
Found existing installation: oauth2client 1.5.2
Uninstalling oauth2client-1.5.2:
Successfully uninstalled oauth2client-1.5.2
Found existing installation: enum34 1.1.2
Uninstalling enum34-1.1.2:
Successfully uninstalled enum34-1.1.2
Successfully installed enum34-1.1.3 oauth2client-2.0.2 protobuf-3.0.0b2.post2 rsa-3.4.2 |
Thanks for the note. Unfortunately there's not much we can do about the way Python packaging works beyond declaring the minimum versions we require. |
The problems are still present using the latest gcloud.
I think I had problematic version 3.0.0b2 cached, that's why it was continued to be used within gcloud.
|
What do you mean by a "problematic version
|
Ahhh hold on:
|
ok...the pain continues.... such a drag to go round & round with this as many times as I have..... |
Here is another guy promoting and publishing the symlink approach.......his is the newest and most consolidated instructions I've found. |
User error (at least in part).....my "venv" folder was part of my skip_files config.....so I guess it would have been deployed to the Production VM if that line was not in there.....but it seem quite weird and inefficient to be loading the WHOLE venv directory rather than just the site-packages subfolder.... |
Okay, lots of stuff to respond to here.
I suspected as such, glad you figured it out.
This is one of many reasons we don't recommend using a virtualenv for vendoring. You can setup
The instructions are here. The vendoring link is broken but it is supposed to link to this heading in the same page. In summary:
These are the steps used in all of our samples for App Engine standard that require third-party packages. From what I understand, this is where things deviated for you:
From what I can gather, you chose this route because It seems my actions here to ameliorate this are:
I feel your pain here, I've been personally working on improving this situation. Please let me know if there's anything more I can do at this time to make this easier. |
Hey Jon..... thanks so much for your diligent responses & help! A few clarifications here: Even though you say I could "setup skip_files to only upload the site-packages folder."....you are specifically recommending AGAINST that approach......correct? |
Yes, I do not recommend using virtualenvs for vendoring on app engine.
I'm not sure what you mean here. I don't think I've recommended that approach elsewhere.
Our documentation shows how to use a simple test runner to do this here. You can also use NoseGAE. If you're extra curious, for testing our own samples we use |
ok...that makes sense.... Sadly, it also created _cffi_backend.so" in my lib directory and I know that's not allowed.....which is weird because I've not seen app engine complain when I've been pushing up there..... |
If you really want to, but they're tiny.
App engine will just ignore it, so don't worry about it. |
I must really be missing something because your "don't worry" comment totally worries me ;-) |
Our Import hooks prevent loading any .so module that isn't explicitly whitelisted. |
Yes, I'm totally clear that it won't get loaded because it won't get pushed by the update......that's not my concern. My concern is that the .so IS THERE in my lib/ directory when testing on localhost, and it WON'T be there on the server......so how can I trust my local testing to be definitive....in other words, some other python package depends upon it?????? |
I should've specified: the import hooks I mentioned are part of dev_appserver. |
oh....all the worry evaporated ;-) Thank you! |
For what it's worth, if anyone else is still having this issue after reading the thread: I solved it in my case by making sure the system-wide Python path was clean of any To clarify, my doing ['/Users/dguaraglia/Projects/project/.env/lib/python2.7/site-packages',
'',
'/Users/dguaraglia/.homebrew/bin',
'/Library/Python/2.7/site-packages',
'/Users/dguaraglia/.homebrew/lib/python2.7/site-packages/gax_google_pubsub_v1-0.7.9-py2.7.egg',
'/Users/dguaraglia/.homebrew/lib/python2.7/site-packages/google_gax-0.12.0-py2.7.egg',
'/Users/dguaraglia/.homebrew/lib/python2.7/site-packages/_pdbpp_path_hack',
'/Users/dguaraglia/.homebrew/lib/python2.7/site-packages/six-1.10.0-py2.7.egg',
...
] After I manually removed the |
Thanks dguaraglia. I got over the issue by renaming all gax files in sys.path, after making sure that timestamp_pb2.py exists in one of the paths in sys.path: /usr/local/lib/python2.7/dist-packages/google_gax-0.12.1-py2.7.egg |
I have same issue
UPD: just installing Traceback:
|
@yanikkoval Some version of some package has stomped on the |
@tseaver It's App Engine weirdness actually. I try to stay away and let @jonparrott weigh in on such issues |
@yanikkoval how are you installing packages? What's in your |
For anyone still having issues this is how I solved it. |
@tseaver, @jonparrott installing it with pip put the package in the wrong directory. |
@yanikkoval can you give us more details? What exact pip command are you running? What's in your |
It is also happening on local machine using Ubuntu 14.04 LTS - from pip freze:
|
@ensonic Run |
which ones should I get rid of - the 'grpc-google-' or 'gapic-google-' |
Neither need be gotten rid of AFAIK. From there you'd want to poke around in |
…loudPlatform/python-docs-samples#1436) * enhanced model and recognition metadata * flake, update tests * readme * client library version update
…loudPlatform/python-docs-samples#1436) * enhanced model and recognition metadata * flake, update tests * readme * client library version update
…loudPlatform/python-docs-samples#1436) * enhanced model and recognition metadata * flake, update tests * readme * client library version update
…loudPlatform/python-docs-samples#1436) * enhanced model and recognition metadata * flake, update tests * readme * client library version update
I'm getting
ImportError: No module named protobuf
from the linefrom google.protobuf import timestamp_pb2
because thegoogle
module refers to the AppEngine SDK.This is a well-known issue that's been around for years. Maybe you can bundle
protobuf
directly insidegcloud-python
instead of an external dependency?The text was updated successfully, but these errors were encountered: