alan-turing-institute / uatk-spc

Synthetic Population Catalyst
https://alan-turing-institute.github.io/uatk-spc/
MIT License
20 stars 12 forks source link

Protobuf library problem (for working with protobuf files) #29

Closed nickmalleson closed 2 years ago

nickmalleson commented 2 years ago

Not an SPC problem specifically, but I am struggling to get the protobuf_to_json.py script to work. (Needed to work with the output of SPC).

I have the protobuf library:

$ pip install protobuf
Requirement already satisfied: protobuf in /Users/nick/opt/anaconda3/envs/py310/lib/python3.10/site-packages (3.20.1)

but the first import line in protobuf_to_json.py https://github.com/alan-turing-institute/uatk-spc/blob/37901a95dfb26feb41d5ac84ce7f8b58d84bce4e/python/protobuf_to_json.py#L1 fails:

(py310) Mac-Pro:synth_pop nick$ python
Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:45:10) [Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.protobuf.json_format import MessageToJson
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google'

Google (search engine and protobuf developer!) is surprisingly unhelpful.

Any ideas? Thanks in advance.

nickmalleson commented 2 years ago

Don't worry, I have used poetry to install the packages and it works. Weird. I installed a few others at the same time that I noticed randomly (like protobuf3, protobuf-extra) so it might have been that. Anyway it's working.

dabreegster commented 2 years ago

Getting Python dependencies installed can be such a headache. :( I thought conda was generally able to see system-wide pip libraries. Not sure what happened here, but glad you sorted it out.

As you start to write Python code to actually use the protobufs, do keep me posted what your experience is like.