protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Unable to import protobuf (compiled and installed) along with google-cloud services

Open dilipvamsi opened this issue 5 years ago • 1 comments

Version: v3.6.1 Language: Python OS: Linux I have installed the python protobuf (c++ implementation) by compiling it from source. This is the folder it got installed into.

$ tree ./venv/lib/python3.6/site-packages/protobuf-3.6.1-py3.6-linux-x86_64.egg/ -L 1
./venv/lib/python3.6/site-packages/protobuf-3.6.1-py3.6-linux-x86_64.egg/
├── EGG-INFO
└── google

I was able to import google.protobuf

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.protobuf
>>>

Then I have installed google-cloud-storage These are the following contents in google site-packages folder.

$ tree ./venv/lib/python3.6/site-packages/google -L 1
./venv/lib/python3.6/site-packages/google
├── api
├── api_core
├── auth
├── cloud
├── logging
├── longrunning
├── oauth2
├── resumable_media
├── rpc
└── type

Unable to import google.protobuf as the python interpreter is unable to find protobuf in ./venv/lib/python3.6/site-packages/google

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.protobuf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.protobuf'
>>> 

What I understood was as the sys.path is favoring ./venv/lib/python3.6/site-packages/google over ./venv/lib/python3.6/site-packages/protobuf-3.6.1-py3.6-linux-x86_64.egg/

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/dilipvamsi/test/venv/lib/python3.6/site-packages', '/home/dilipvamsi/test/venv/lib/python3.6/site-packages/six-1.12.0-py3.6.egg', '/home/dilipvamsi/test/venv/lib/python3.6/site-packages/protobuf-3.6.1-py3.6-linux-x86_64.egg']

So, I have created a symbolic link from google folder to installed protobuf

$ cd ./venv/lib/python3.6/site-packages/google
$ ln -s ../protobuf-3.6.1-py3.6-linux-x86_64.egg/google/protobuf/ protobuf

Then I was able to import it. Is there any way to get it working just by installing.

Thanks, Dilip Vamsi.

dilipvamsi avatar Feb 12 '19 13:02 dilipvamsi

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar May 05 '24 10:05 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar May 19 '24 10:05 github-actions[bot]