Search code examples
pythonmodulepycharmpydrive

PyCharm recognize a module but do not import it


I try to import the PyDrive module in my PyCharm project : from pydrive.auth import GoogleAuth. I tried different things :

  • Installing it directly from the project interpreter
  • Download it with a pip command and import it with the path for the poject interpreter
  • The same thing in Linux

Nothing works. Each time PyCharm recognize the module and even sugest the auto-completion, but when I run the project it keeps saying ImportError: No module named pydrive.auth

Any suggestion ?

EDIT : When I put directly the pydrive folder in my repository, and this time : ImportError: No module named httplib2 from the first import of PyDrive. My path is correct and httplib2 is again in my PyCharm project


Solution

  • After noticing that the module is already installed, both by pip and by the project interpreter, and nothing worked, this what did the trick (finaly!):

    1. make sure the module is indeed installed:

      sudo pip{2\3} install --upgrade httplib2

    2. locate the module on your computer:

      find / | grep httplib2

    you will need to reach the place in which pip is installing the module, the path would probably look like this:

    /usr/local/lib/python2.7/dist-packages

    1. get into the path specified there, search for the module and copy all the relevant files and folders into your local pycharm project environment. this will be a directory with a path like this:

      /home/your_user/.virtualenvs/project_name/lib/python2.7

    this is it. note however you may need to do this multiple times, since each module may have a dependencies...

    good luck!