Je travaille avec Python 2.7.10.
J'essaie juste d'exécuter à partir du stockage d'importation google.cloud
, mais j'obtiens ImportError: Aucun module nommé google. cloud
.
google-cloud semble être installé correctement. pip install google-cloud
renvoie Exigence déjà satisfaite: google-cloud dans /Library/Python/2.7/site-packages (0.34.0)
et pip show google-cloud
renvoie:
Using cached https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl protobuf 3.6.1 has requirement six>=1.9, but you'll have six 1.4.1 which is incompatible. google-api-core 1.7.0 has requirement six>=1.10.0, but you'll have six 1.4.1 which is incompatible. google-auth 1.6.2 has requirement six>=1.9.0, but you'll have six 1.4.1 which is incompatible. Installing collected packages: setuptools, protobuf, googleapis-common-protos, urllib3, certifi, chardet, idna, requests, futures, pyasn1, rsa, pyasn1-modules, cachetools, google-auth, google-api-core, google-cloud-core, google-resumable-media, google-cloud-storage Found existing installation: setuptools 18.5 Uninstalling setuptools-18.5: Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
EDIT: merci à Duy ci-dessous pour m'avoir rappelé la prochaine étape.
L'exécution de pip install google-cloud-storage
génère un tas d'erreurs:
Name: google-cloud Version: 0.34.0 Summary: API Client library for Google Cloud Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python Author: Google Cloud Platform Author-email: googleapis-publisher@google.com License: Apache 2.0 Location: /Library/Python/2.7/site-packages Requires: Required-by:
Je ne comprends pas ce qu'est l'erreur d'environnement, et tout mon les recherches portent sur des terriers de lapin inutiles.
3 Réponses :
Vous oubliez d'installer pip install google-cloud-storage
J'ai oublié de le mentionner au moins. C'est là que les choses deviennent vraiment bizarres, désolé, j'ai oublié de l'inclure dans ma question principale. Permettez-moi de mettre à jour mon message afin d'avoir un accès complet au formatage.
Le package google-cloud
est obsolète, vous doit le désinstaller et installer google-cloud-storage
à la place.
Je vous remercie! Voir ma modification, car cela pose un problème d'environnement. Dois-je désinstaller google-cloud?
Vous devez désinstaller google-cloud
, puis réinstaller google-cloud-storage
. Les erreurs ne semblent pas liées, il semble que vous ayez peut-être sudo pip installé
par erreur et que vous ne disposez pas des autorisations de désinstallation.
Vous devez utiliser un environnement python.
pip install virtualenv virtualenv <your-env> source <your-env>/bin/activate <your-env>/bin/pip install google-cloud-python
Cliquez ici pour plus de détails sur virtualenv
https://cloud.google.com/python/setup
Ah, génial! Merci, cela semble l'avoir fait. Je comprends pourquoi l'utilisation d'un environnement est utile, mais je ne comprends pas pourquoi il était nécessaire dans ce cas. Peux-tu élaborer?
Ces environnements isolés peuvent avoir leurs propres versions distinctes de packages Python, ce qui vous permet d'isoler les dépendances de vos projets des dépendances d'autres projets. Je vous recommande de toujours utiliser un virtualenv
par projet lors du développement local avec Python.
Pip vous indique que vous avez des packages qui sont anciens (non compatibles) avec google-cloud-storage. Ajoutez l'option de mise à niveau à pip:
pip install -U google-cloud-storage
. Pip va maintenant mettre à niveausix
vers une version prise en charge à condition que cette mise à niveau n'entre pas en conflit avec d'autres packages déjà installés.@JohnHanley L'utilisation d'un environnement dédié fonctionnait, mais je ne comprenais pas pourquoi. Je pense que cela doit être parce que cela a permis que tout soit installé à partir de zéro. Je vous remercie!