When pip
tells you that you already have protobuf
,
but PyCharm (or other) tells you that you don't have it,
it means that pip
and PyCharm are using a different Python interpreter.
This is a very common issue, especially on a Mac, with no standard Python package management.
The best way to completely eliminate such issues is using a virtualenv
per Python project, which is essentially a directory of Python packages and environment variable settings to isolate the Python environment of the project from everything else.
Create a virtualenv
for your project like this:
cd project
virtualenv --distribute virtualenv -p /path/to/python/executable
This creates a directory called virtualenv
inside your project.
(Make sure to configure your VCS (for example Git) to ignore this directory.)
To install packages in this virtualenv
, you need to activate the environment variable settings:
. virtualenv/bin/activate
Verify that pip
will use the right Python executable inside the virtualenv
, by running pip -V
. It should tell you the Python library path used, which should be inside the virtualenv
.
Now you can use pip
to install protobuf
as you did.
And finally, you need to make PyCharm use this virtualenv
instead of the system libraries. Somewhere in the project settings you can configure an interpreter for the project, select the Python executable inside the virtualenv
.