Pygithub: ImportError: aucun module nommé github

CrĂ©Ă© le 7 aoĂ»t 2018  Â·  43Commentaires  Â·  Source: PyGithub/PyGithub

J'essaye d'utiliser PyGitHub et j'obtiens "ImportError: No module named github".

Spécifications de configuration:
macOS v10.13.6
Python v3.7.0
Installé avec pip v18.0

bug high priority

Commentaire le plus utile

cela casse en python 3.7

Je suis d'accord, je viens de le tester. Lorsque vous utilisez Python 3.7+, vous obtenez l'erreur suivante:

Traceback (most recent call last):
  File "scripts/src/create_release.py", line 6, in <module>
    from github.Milestone import Milestone
ModuleNotFoundError: No module named 'github'

L'utilisation de Python 3.6 fonctionne trĂšs bien.

Tous les 43 commentaires

Changer votre répertoire actuel et réessayer?

Voulez-vous simplement déplacer le script vers un autre répertoire et réessayer? Si c'est ce que tu voulais dire, j'ai essayé et rien n'a changé.

Le nom de votre script est-il Ă©galement "github"?

Non, le script Python ne s'appelle pas "github".

Comme je n'ai pas du tout utilisé la bibliothÚque, j'essayais simplement d'utiliser l'exemple de code fourni dans le README.md

screen shot 2018-08-07 at 5 33 05 pm

@JosephTLyons Avez-vous exécuté $ pip install pygithub avant d'essayer d'utiliser la bibliothÚque?

Oui je l'ai fait. Et si je l'exécute à nouveau, je reçois ces messages pour le confirmer.

Josephs-MBP-15:~ josephlyons$ pip install pygithub
Requirement already satisfied: pygithub in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.40)
Requirement already satisfied: requests>=2.14.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pygithub) (2.19.1)
Requirement already satisfied: pyjwt in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pygithub) (1.6.4)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (1.23)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2018.4.16)
Requirement already satisfied: idna<2.8,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2.7)

Salut, @JosephTLyons avez-vous installé py2 et py3 ensemble dans votre MBP?
Si vous le faites, confirmez que la configuration de votre interpréteur IDE est identique à celle de votre installation pip.
comme l'image ci-dessous
image
et ma configuration d'interpréteur IDE est
image

@JosephTLyons Essayez d'exécuter le script sur un terminal .... Si cela fonctionne avec succÚs, votre IDE est mal configuré

J'ai à la fois python 2 (la version Apple est livrée avec leur mac) et python3 (installé via Homebrew).

De plus, j'exécute le script via Terminal, je n'utilise pas d'IDE. Je codifie strictement avec Atom, puis je cours avec Terminal.

Continuez avec moi, mĂȘme si je ne suis pas un nouveau programmeur, je suis nouveau sur Python et c'est l'un des premiers modules Python que j'ai essayĂ© d'utiliser qui n'a pas rĂ©ussi pour moi.

screen shot 2018-08-12 at 4 54 04 am

J'ai le mĂȘme problĂšme. J'ai crĂ©Ă© un environnement virtuel et essayĂ© d'installer PyGithub Ă  l'aide de pip install PyGithub. J'ai reçu: Exigence dĂ©jĂ  satisfaite (utilisez --upgrade pour mettre Ă  niveau): pygithub dans /myvenv/lib/python3.5/site-packages
Exigence dĂ©jĂ  satisfaite (utilisez --upgrade pour mettre Ă  niveau): requĂȘtes> = 2.14.0 dans /myvenv/lib/python3.5/site-packages (de pygithub)
Exigence déjà satisfaite (utilisez --upgrade pour mettre à niveau): pyjwt dans /myvenv/lib/python3.5/site-packages (à partir de pygithub)
Exigence déjà satisfaite (utilisez -upgrade pour mettre à niveau): idna <2.8,> = 2.5 dans /myvenv/lib/python3.5/site-packages (from requests> = 2.14.0-> pygithub)
Exigence déjà satisfaite (utilisez -upgrade pour mettre à niveau): chardet <3.1.0,> = 3.0.2 dans /myvenv/lib/python3.5/site-packages (à partir de demandes> = 2.14.0-> pygithub)
Exigence déjà satisfaite (utilisez --upgrade pour mettre à niveau): certifi> = 2017.4.17 dans /myvenv/lib/python3.5/site-packages (à partir de demandes> = 2.14.0-> pygithub)
Exigence déjà satisfaite (utilisez -upgrade pour mettre à niveau): urllib3 <1.24,> = 1.21.1 dans /myvenv/lib/python3.5/site-packages (à partir de demandes> = 2.14.0-> pygithub)

J'ai essayé d'importer la bibliothÚque en utilisant python via un terminal, mais ... sans succÚs
sem titulo
sem titulo2

Un virtualenv Python 2 résout-il le problÚme?

LĂ  oĂč il sera utilisĂ©, python 2 n'est pas utilisĂ© en raison d'un conflit.

Cela semble ĂȘtre un problĂšme connu ennuyeux, laissez-moi enquĂȘter et essayer de le rĂ©soudre.

Peut-ĂȘtre un problĂšme de PIP?

Je me souviens avoir eu ce problĂšme (avec un autre module) sur Linux Mate.

Si le problĂšme persiste, installez pip Ă  partir de la derniĂšre branche principale, oĂč je viens de corriger un problĂšme d'importation dans de6b713b0.

Les commentaires du n ° 314 valent également le détour.

MĂȘme problĂšme.

Essayez d'installer pygithub avec cette commande: python -m pip install pygithub

Cela garantit que vous utilisez le pip associé à l'interpréteur python avec lequel vous exécutez le script.

je l'ai fait:
python3 -m venv myvenv
J'ai activé l'environnement et ensuite:
python -m pip install pygithub

Collecting pygithub
  Downloading https://files.pythonhosted.org/packages/91/9e/50af4bb0ab316fedc13ae87347a718c19698ba8a19e64a692dc30c5fc9db/PyGithub-1.43.2.tar.gz (2.7MB)
    100% |████████████████████████████████| 2.7MB 647kB/s 
Collecting requests>=2.14.0 (from pygithub)
  Using cached https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Collecting pyjwt (from pygithub)
  Using cached https://files.pythonhosted.org/packages/93/d1/3378cc8184a6524dc92993090ee8b4c03847c567e298305d6cf86987e005/PyJWT-1.6.4-py2.py3-none-any.whl
Collecting Deprecated (from pygithub)
  Downloading https://files.pythonhosted.org/packages/83/2d/7a5a117eccdef0cdf4cf015830945a7d8fdbbc9ec866d7cead758dc4229c/Deprecated-1.2.3-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.14.0->pygithub)
  Downloading https://files.pythonhosted.org/packages/df/f7/04fee6ac349e915b82171f8e23cee63644d83663b34c539f7a09aed18f9e/certifi-2018.8.24-py2.py3-none-any.whl (147kB)
    100% |████████████████████████████████| 153kB 3.3MB/s 
Collecting urllib3<1.24,>=1.21.1 (from requests>=2.14.0->pygithub)
  Using cached https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.14.0->pygithub)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.8,>=2.5 (from requests>=2.14.0->pygithub)
  Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
Collecting wrapt<2,>=1 (from Deprecated->pygithub)
  Downloading https://files.pythonhosted.org/packages/a0/47/66897906448185fcb77fc3c2b1bc20ed0ecca81a0f2f88eda3fc5a34fc3d/wrapt-1.10.11.tar.gz
Building wheels for collected packages: pygithub, wrapt
  Running setup.py bdist_wheel for pygithub ... error
  Complete output from command /home/leonardo/phub/myvenv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yww1918p/pygithub/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpx2l6hyczpip-wheel- --python-tag cp35:
  /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
    warnings.warn(msg)
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for pygithub
  Running setup.py clean for pygithub
  Running setup.py bdist_wheel for wrapt ... error
  Complete output from command /home/leonardo/phub/myvenv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yww1918p/wrapt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp4kz97gl4pip-wheel- --python-tag cp35:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for wrapt
  Running setup.py clean for wrapt
Failed to build pygithub wrapt
Installing collected packages: certifi, urllib3, chardet, idna, requests, pyjwt, wrapt, Deprecated, pygithub
  Running setup.py install for wrapt ... done
  Running setup.py install for pygithub ... done
Successfully installed Deprecated-1.2.3 certifi-2018.8.24 chardet-3.0.4 idna-2.7 pygithub-1.43.2 pyjwt-1.6.4 requests-2.19.1 urllib3-1.23 wrapt-1.10.11
You are using pip version 8.1.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

J'ai essayé d'exécuter un script en utilisant pygithub et cela n'a renvoyé aucune erreur.

il est bon d'essayer d'exécuter d'abord le script à partir de la ligne de commande de l'environnement virtuel.

Celles-ci peuvent ĂȘtre causĂ©es par les importations relatives. Python 3 nĂ©cessite des importations absolues. Cela devrait ĂȘtre corrigĂ© par # 967

sudo pip3 install pygithub fonctionné pour moi.

cela rompt dans python 3.7+ mais fonctionne dans 3.6.5 FYI
mais je ne sais pas s'il s'agit d'un problĂšme de pip car 3.7.2 utilise pip 18 mais 3.6.5 utilise 9.x

cela casse en python 3.7

Je suis d'accord, je viens de le tester. Lorsque vous utilisez Python 3.7+, vous obtenez l'erreur suivante:

Traceback (most recent call last):
  File "scripts/src/create_release.py", line 6, in <module>
    from github.Milestone import Milestone
ModuleNotFoundError: No module named 'github'

L'utilisation de Python 3.6 fonctionne trĂšs bien.

Cela ne fonctionne toujours pas sur Python 3.7 ??? Je reçois toujours une erreur lors de l'importation?

@ conoroshea1996, ils ont refusé de résoudre ce problÚme dans le passé malgré plusieurs PR pour le résoudre.

J'ai le mĂȘme problĂšme lorsque j'utilise Pycharm sur Mac OS, mais je n'ai pas ce problĂšme lorsque j'utilise Jupyter sur Mac OS. Et, je n'ai pas ce problĂšme lorsque j'utilise Pycharm ou Jupyter sous Windows.

+1
Python 3.7.4 J'obtiens la mĂȘme erreur.

@ p3nda Ce n'est certainement pas le mĂȘme problĂšme que prĂ©cĂ©demment, pouvez-vous afficher l'erreur complĂšte?

Salut @stevenk,
Chose sûre:

python3 --version
Python 3.7.4

Je reçois:

ImportError: impossible d'importer le nom 'Github' depuis 'github' (/usr/local/lib/python3.7/site-packages/github/__init__.py)

J'ai pensé que cette erreur était légÚrement différente, donc aprÚs un dépannage pendant un certain temps sans succÚs, j'ai créé un conteneur Docker et installé python3.6 et essayé de l'utiliser:

ImportError: impossible d'importer le nom 'Github'
python3 --version
Python 3.6.9

@ p3nda Sur quelle plateforme?

@stevenk Pour la premiĂšre erreur sur python3.7.4, j'utilise macos mojave 10.14.6. Dans le conteneur Docker avec python 3.6.9, j'utilise Ubuntu 18.04.3

Alors c'est bizarre, qu'est-ce que ça fait:

>>> import github
>>> github.__file__
'/home/steven/PyGithub/github/__init__.py'
>>> dir(github.MainClass)
['AuthenticatedUser', 'Consts', 'DEFAULT_BASE_URL', 'DEFAULT_PER_PAGE', 'DEFAULT_STATUS_URL', 'DEFAULT_TIMEOUT', 'Github', 'GithubException', 'GithubIntegration', 'GitignoreTemplate', 'HookDescription', 'Installation', 'InstallationAuthorization', 'RateLimit', 'Repository', 'Requester', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'datetime', 'github', 'jwt', 'pickle', 'requests', 'time', 'urllib3']
>>> github.MainClass.__file__
'/home/steven/PyGithub/github/MainClass.py'

te donner?

Et from github.MainClass import Github désolé

Dans le conteneur Docker Ubuntu 18.04:

importer github
Traceback (dernier appel le plus récent):
DĂ©poser "", ligne 1, dans
Fichier "/usr/local/lib/python3.6/dist-packages/github/__init__.py", ligne 44, dans
depuis github.MainClass import Github, GithubIntegration
Fichier "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", ligne 58, dans
demandes d'importation
Fichier "/usr/local/lib/python3.6/dist-packages/requests/__init__.py", ligne 112, dans
de . importer des utilitaires
Fichier "/usr/local/lib/python3.6/dist-packages/requests/utils.py", ligne 26, dans
depuis ._internal_utils importer vers_native_string
Fichier "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", ligne 11, dans
Ă  partir de .compat import is_py2, builtin_str, str
Fichier "/usr/local/lib/python3.6/dist-packages/requests/compat.py", ligne 59, dans
depuis http importer cookiejar comme cookielib
Fichier "/usr/lib/python3.6/http/cookiejar.py", ligne 31, dans
importer une copie
Fichier "/copy.py", ligne 2, dans
depuis github import Github
ImportError: impossible d'importer le nom 'Github'

depuis github.MainClass import Github
Traceback (dernier appel le plus récent):
DĂ©poser "", ligne 1, dans
Fichier "/usr/local/lib/python3.6/dist-packages/github/__init__.py", ligne 44, dans
Ă  partir de github.MainClass import Github, GithubIntegration
Fichier "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", ligne 58, dans
demandes d'importation
Fichier "/usr/local/lib/python3.6/dist-packages/requests/__init__.py", ligne 112, dans
de . importer des utilitaires
Fichier "/usr/local/lib/python3.6/dist-packages/requests/utils.py", ligne 26, dans
depuis ._internal_utils importer vers_native_string
Fichier "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", ligne 11, dans
Ă  partir de .compat import is_py2, builtin_str, str
Fichier "/usr/local/lib/python3.6/dist-packages/requests/compat.py", ligne 59, dans
depuis http importer cookiejar comme cookielib
Fichier "/usr/lib/python3.6/http/cookiejar.py", ligne 31, dans
importer une copie
Fichier "/copy.py", ligne 2, dans
depuis github import Github
ImportError: impossible d'importer le nom 'Github'

Sur mon Mac:

importer github
Traceback (dernier appel le plus récent):
DĂ©poser "", ligne 1, dans
Fichier "/usr/local/lib/python3.7/site-packages/github/__init__.py", ligne 44, dans
Ă  partir de github.MainClass import Github, GithubIntegration
Fichier "/usr/local/lib/python3.7/site-packages/github/MainClass.py", ligne 58, dans
demandes d'importation
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", ligne 112, dans
de . importer des utilitaires
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", ligne 26, dans
depuis ._internal_utils importer vers_native_string
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", ligne 11, dans
Ă  partir de .compat import is_py2, builtin_str, str
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", ligne 59, dans
depuis http importer cookiejar comme cookielib
Fichier "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", ligne 31, dans
importer une copie
Fichier "/Users/amanda/copy.py", ligne 2, dans
depuis github import Github
ImportError: impossible d'importer le nom 'Github' depuis 'github' (/usr/local/lib/python3.7/site-packages/github/__init__.py)

depuis github.MainClass import Github
Traceback (dernier appel le plus récent):
DĂ©poser "", ligne 1, dans
Fichier "/usr/local/lib/python3.7/site-packages/github/__init__.py", ligne 44, dans
Ă  partir de github.MainClass import Github, GithubIntegration
Fichier "/usr/local/lib/python3.7/site-packages/github/MainClass.py", ligne 58, dans
demandes d'importation
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", ligne 112, dans
de . importer des utilitaires
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", ligne 26, dans
depuis ._internal_utils importer vers_native_string
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", ligne 11, dans
Ă  partir de .compat import is_py2, builtin_str, str
Fichier "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", ligne 59, dans
depuis http importer cookiejar comme cookielib
Fichier "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", ligne 31, dans
importer une copie
Fichier "/Users/amanda/copy.py", ligne 2, dans
depuis github import Github
ImportError: impossible d'importer le nom 'Github' depuis 'github' (/usr/local/lib/python3.7/site-packages/github/__init__.py)

Je dois noter que je suis sur ma machine de travail ce matin en train de faire le test du macbook qui est
MacOS Mojave 10.14.6 avec python 3.7.5 installĂ©. Pour le conteneur ubuntu, c'est le mĂȘme, la mĂȘme version de python.

@stevenk

File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", line 31, in
import copy
File "/Users/amanda/copy.py", line 2, in 

D'oĂč vient ce fichier /copy.py ou /Users/amanada/copy.py? Il masque un vrai module Python /usr/lib/python3.6/copy.py et provoque une importation circulaire.

copy.py est un script sur lequel je travaillais et qui utilise PyGithub. Lorsque j'ai exĂ©cutĂ© ces commandes, elles ont Ă©tĂ© exĂ©cutĂ©es Ă  partir de l'interprĂ©teur python lui-mĂȘme aprĂšs avoir essayĂ© d'exĂ©cuter le script. J'ai crĂ©Ă© un nouveau conteneur sans exĂ©cuter ce script et j'ai simplement exĂ©cutĂ© les commandes d'importation via l'interprĂ©teur python et fonctionne bien:

importer github
depuis github import Github
sortir()

Je ne sais pas pourquoi l'ajout dans mon script a tout cassĂ©, il n'est mĂȘme pas encore complĂštement formĂ©:

import shutil
depuis github import Github

ACCESS_TOKEN = '123456789'

initialiser le client github

g = Github (ACCESS_TOKEN)
impression (g.get_user (). get_repos ())

@stevenk

Il a tout cassé à cause du nom - il masque un module Python appelé 'copy' qui se trouve dans la chaßne d'importation de modules lorsque vous exécutez from github import Github . Appelez votre script autre chose et cela devrait fonctionner correctement.

Ah d'accord, merci pour la clarté @stevenk j'apprécie votre temps!

@ p3nda Je suis ravi d'aider! Je vais fermer ce problÚme, si vous rencontrez d'autres problÚmes, n'hésitez pas à en ouvrir un nouveau.

Quelqu'un peut-il m'aider avec cette erreur

Traceback (dernier appel le plus récent):
Fichier "terra.py", ligne 1, dans
Ă  partir de l'importation python_terraform *
ImportError: aucun module nommé python_terraform

Dans mon cas, j'ai eu cette erreur en raison de problĂšmes avec mon chemin d'importation Python.

J'utilise Python 3.7.3:

$ python3 --version
Python 3.7.3

Et PyPI 20.2.3:

$ pip3 --version
pip 20.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

J'ai installé PyGithub:

$ pip3 install pygithub
Requirement already satisfied: pygithub in /usr/local/lib/python3.7/site-packages (1.43)
Requirement already satisfied: pyjwt in /usr/local/lib/python3.7/site-packages (from pygithub) (1.7.1)
Requirement already satisfied: requests>=2.14.0 in /usr/local/lib/python3.7/site-packages (from pygithub) (2.24.0)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2.10)

Mais, il ne parvient pas à importer, néanmoins:

$ python3 <<< "from github import Github"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'github'

Dans la sortie pip, nous avons vu que le package était installé sur /usr/local/lib/python3.7/site-packages . Cependant, ce répertoire n'était __pas__ dans le chemin des importations Python:

$ python3 <<< 'import sys; print(sys.path)'
['', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python37.zip', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/jhwill/Library/Python/3.7/lib/python/site-packages', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages']

Solution 1: Ajouter Ă  PYTHONPATH

Une façon de résoudre ce problÚme est d'ajouter le répertoire manquant à mon PYTHONPATH , dans ~/.bashrc :

# Add these lines
readonly local_site_packages="/usr/local/lib/python3.7/site-packages"
if [ ! -z "$PYTHONPATH" ]; then
    export PYTHONPATH="$local_site_packages:$PYTHONPATH"
else
    export PYTHONPATH="$local_site_packages"
fi

Et source le fichier:

$ . ~/.bashrc

Solution 2: installer sur un chemin d'importation existant

/Users/jhwill/Library/Python/3.7/lib/python/site-packages est déjà dans mon chemin systÚme. Ainsi, nous pouvons cibler ce répertoire pour l'installation en utilisant la commande pip3 :

$ pip install --target=/Users/jhwill/Library/Python/3.7/lib/python/site-packages PyGithub
Collecting PyGithub
  Using cached PyGithub-1.53-py3-none-any.whl (274 kB)
Collecting pyjwt
  Using cached PyJWT-1.7.1-py2.py3-none-any.whl (18 kB)
Collecting deprecated
  Using cached Deprecated-1.2.10-py2.py3-none-any.whl (8.7 kB)
Collecting requests>=2.14.0
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Processing ./Library/Caches/pip/wheels/62/76/4c/aa25851149f3f6d9785f6c869387ad82b3fd37582fa8147ac6/wrapt-1.12.1-cp37-cp37m-macosx_10_14_x86_64.whl
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
     |████████████████████████████████| 127 kB 2.9 MB/s 
Installing collected packages: pyjwt, wrapt, deprecated, idna, chardet, certifi, urllib3, requests, PyGithub
Successfully installed PyGithub-1.53 certifi-2020.6.20 chardet-3.0.4 deprecated-1.2.10 idna-2.10 pyjwt-1.7.1 requests-2.24.0 urllib3-1.25.10 wrapt-1.12.1
Cette page vous a été utile?
0 / 5 - 0 notes