Forums

pycrypto import issue

Hello!

I have some trouble with pycrypto library, I'm testing the pyDrive library in a test.py file on medaoperator account and I simply run the authenticatiom code as below:

from pydrive.drive import GoogleDrive
import os

THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
my_file = os.path.join(THIS_FOLDER, 'client_secrets.json')

GoogleAuth.DEFAULT_SETTINGS['client_config_file'] = my_file
gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)

but whe I run this code I got the error:

pydrive.settings.InvalidConfigError: Invalid client secrets file ('Error opening file', '/home/medaoperator/maima/client_secrets.json', 'No such file or directory', 2)

The client_secrets.json file is correctly present in maima folder. Searching in Stackoverflow I found the explanation for thi issue in this link: https://stackoverflow.com/questions/25143263/service-account-and-pydrive , which says: "After some more research it seems like I needed to install pycrypto to fix the import error described above. I don't know why as it is not specified in the error message."

In the Python console I tried to import pycrypto, no module found.

In the command line console I tried to run:

pip install --user pycrypto: Requirement already satisfied (use --upgrade to upgrade): pycrypto in /usr/local/lib/python2.7/dist-packages

Impossible to remove and reinstall pycrypto, access deniend, since the package is not installed as local user's library.

If I try to upgrade I got the message "Requirement already up-to-date: pycrypto in /usr/local/lib/python2.7/dist-packages"

pip2.7 freeze  ====> pycrypto==2.6.1

pip list --user shows the list below: "pip install --user pycrypto" and "pip2.7 install --user pycrypto" does not work.

cachetools (2.0.1)
Flask-SSLify (0.1.5)
google (1.9.3)
google-api-python-client (1.6.4)
google-auth (1.2.0)
gspread (0.6.2)
httplib2 (0.10.3)
oauth2client (4.1.2)
pyasn1 (0.3.7)
pyasn1-modules (0.1.5)
PyDrive (1.3.1)
six (1.11.0)
uritemplate (3.0.0)

Is there a way to fix this issue?

Best regards, Fabio

Try

pip install --user --upgrade pycrypto

Or using a virtualenv. More info here: https://help.pythonanywhere.com/pages/InstallingNewModules