Pygithub: ImportError: Kein Modul namens github

Erstellt am 7. Aug. 2018  ·  43Kommentare  ·  Quelle: PyGithub/PyGithub

Ich versuche PyGitHub zu verwenden und erhalte die Meldung "ImportError: Kein Modul mit dem Namen github".

Setup-Spezifikationen:
macOS v10.13.6
Python v3.7.0
Installiert mit pip v18.0

bug high priority

Hilfreichster Kommentar

Dies bricht in Python 3.7

Ich stimme zu, habe es gerade getestet. Bei Verwendung von Python 3.7+ wird der folgende Fehler angezeigt:

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'

Die Verwendung von Python 3.6 funktioniert einwandfrei.

Alle 43 Kommentare

Ändern Sie Ihr aktuelles Verzeichnis und versuchen Sie es erneut?

Meinen Sie einfach das Skript in ein anderes Verzeichnis verschieben und es erneut versuchen? Wenn du das gemeint hast, habe ich es versucht und nichts hat sich geändert.

Ist Ihr Skriptname auch "github"?

Nein, das Python-Skript heißt nicht "github".

Da ich die Bibliothek überhaupt nicht verwendet habe, habe ich nur versucht, den Beispielcode zu verwenden, der in README.md

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

@JosephTLyons Haben Sie $ pip install pygithub bevor Sie versucht haben, die Bibliothek zu verwenden?

Ja, habe ich. Und wenn ich es erneut starte, erhalte ich diese Meldungen, um es zu bestätigen.

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)

Hallo, @JosephTLyons hast du py2 und py3 zusammen in deinem MBP installiert?
Wenn Sie dies tun, bestätigen Sie, dass Ihre IDE-Interpreter-Konfiguration mit Ihrer Pip-Installation übereinstimmt
wie das Bild unten
image
und meine IDE-Interpreter-Konfiguration ist
image

@JosephTLyons Versuchen Sie, das Skript auf einem Terminal auszuführen. Wenn dies erfolgreich ausgeführt wird, ist Ihre IDE schlecht konfiguriert

Ich habe sowohl Python 2 (die Version, die Apple mit ihrem Mac liefert) als auch Python3 (über Homebrew installiert).

Außerdem führe ich das Skript über das Terminal aus und verwende keine IDE. Ich codiere streng mit Atom und laufe dann mit Terminal.

Ich bin zwar kein neuer Programmierer, aber ich bin neu in Python und dies ist eines der ersten Python-Module, die ich zu verwenden versucht habe und die für mich nicht erfolgreich waren.

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

Ich habe das gleiche Problem. Ich habe eine virtuelle Umgebung erstellt und versucht, PyGithub mit pip install PyGithub zu installieren. Ich habe erhalten: Anforderung bereits erfüllt (verwenden Sie --upgrade zum Aktualisieren): pygithub in /myvenv/lib/python3.5/site-packages
Anforderung bereits erfüllt (zum Aktualisieren --upgrade verwenden): Anfragen> = 2.14.0 in /myvenv/lib/python3.5/site-packages (von pygithub)
Voraussetzung bereits erfüllt (zum Aktualisieren --upgrade verwenden): pyjwt in /myvenv/lib/python3.5/site-packages (von pygithub)
Anforderung bereits erfüllt (zum Aktualisieren -upgrade verwenden): idna <2.8,> = 2.5 in /myvenv/lib/python3.5/site-packages (aus Anfragen> = 2.14.0-> pygithub)
Anforderung bereits erfüllt (zum Aktualisieren -upgrade verwenden): chardet <3.1.0,> = 3.0.2 in /myvenv/lib/python3.5/site-packages (aus Anfragen> = 2.14.0-> pygithub)
Anforderung bereits erfüllt (zum Aktualisieren --upgrade verwenden): certifi> = 2017.4.17 in /myvenv/lib/python3.5/site-packages (aus Anfragen> = 2.14.0-> pygithub)
Anforderung bereits erfüllt (zum Aktualisieren -upgrade verwenden): urllib3 <1.24,> = 1.21.1 in /myvenv/lib/python3.5/site-packages (aus Anfragen> = 2.14.0-> pygithub)

Ich habe versucht, die Bibliothek mit Python über das Terminal zu importieren, aber ... kein Erfolg
sem titulo
sem titulo2

Löst eine Python 2-Virtualenv das Problem?

Wo es verwendet wird, wird Python 2 aufgrund von Konflikten nicht verwendet.

Dies scheint ein lästiges bekanntes Problem zu sein. Lassen Sie mich das untersuchen und versuchen, es zu beheben.

Kann ein Problem von PIP sein?

Ich erinnere mich, dass ich dieses Problem (mit einem anderen Modul) unter Linux Mate hatte.

Wenn dies immer noch ein Problem ist, installieren Sie pip aus dem neuesten Hauptzweig, wo ich gerade ein Importproblem in de6b713b0 behoben habe.

Auch Kommentare in # 314 sind einen Blick wert.

Gleicher Fehler.

Versuchen Sie, pygithub mit dem folgenden Befehl zu installieren: python -m pip install pygithub

Dadurch wird sichergestellt, dass Sie den Pip verwenden, der sich auf den Python-Interpreter bezieht, mit dem Sie das Skript ausführen.

ich hab es gemacht:
python3 -m venv myvenv
Ich habe die Umgebung aktiviert und dann:
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.

Ich habe versucht, ein Skript mit pygithub auszuführen, aber es hat keinen Fehler zurückgegeben.

Es ist gut zu versuchen, das Skript zuerst über die Befehlszeile der virtuellen Umgebung auszuführen.

Diese können durch die relativen Importe verursacht werden. Python 3 erfordert absolute Importe. Dies sollte durch # 967 behoben werden

sudo pip3 install pygithub hat bei mir funktioniert.

Dies bricht in Python 3.7+, funktioniert aber in 3.6.5 FYI
Ich bin mir jedoch nicht sicher, ob es sich um ein Pip-Problem handelt, da 3.7.2 Pip 18 verwendet, 3.6.5 jedoch 9.x.

Dies bricht in Python 3.7

Ich stimme zu, habe es gerade getestet. Bei Verwendung von Python 3.7+ wird der folgende Fehler angezeigt:

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'

Die Verwendung von Python 3.6 funktioniert einwandfrei.

Funktioniert das unter Python 3.7 immer noch nicht ??? Ich bekomme immer noch Fehler beim Importieren?

@ conoroshea1996 Sie haben sich in der Vergangenheit trotz mehrerer PRs geweigert, dies zu beheben.

Ich habe das gleiche Problem, wenn ich Pycharm unter Mac OS verwende, aber ich habe dieses Problem nicht, wenn ich Jupyter unter Mac OS verwende. Und ich habe dieses Problem nicht, wenn ich Pycharm oder Jupyter unter Windows verwende.

+1
Python 3.7.4 Ich erhalte den gleichen Fehler.

@ p3nda Dies ist mit ziemlicher Sicherheit nicht das gleiche Problem wie zuvor gemeldet. anzeigen ?

Hallo @stevenk,
Sichere Sache:

python3 --version
Python 3.7.4

Ich bekomme:

ImportError: Name 'Github' kann nicht aus 'github' importiert werden (/usr/local/lib/python3.7/site-packages/github/__init__.py)

Ich habe festgestellt, dass dieser Fehler etwas anders ist. Nach einer Weile erfolgloser Fehlerbehebung habe ich einen Docker-Container hochgefahren, python3.6 installiert und versucht, ihn zu verwenden:

ImportError: Name 'Github' kann nicht importiert werden
python3 --version
Python 3.6.9

@ p3nda Auf welcher Plattform?

@stevenk Für den ersten Fehler in Python3.7.4 verwende ich MacOS Mojave 10.14.6. Im Docker-Container mit Python 3.6.9 verwende ich Ubuntu 18.04.3

Es ist also seltsam, was macht:

>>> 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'

gebe dir?

Und from github.MainClass import Github sorry

In Ubuntu 18.04 Docker Container:

Github importieren
Traceback (letzter Anruf zuletzt):
Datei "", Zeile 1, in
Datei "/usr/local/lib/python3.6/dist-packages/github/__init__.py", Zeile 44, in
aus github.MainClass importieren Github, GithubIntegration
Datei "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", Zeile 58, in
Importanforderungen
Datei "/usr/local/lib/python3.6/dist-packages/requests/__init__.py", Zeile 112, in
von . Utils importieren
Datei "/usr/local/lib/python3.6/dist-packages/requests/utils.py", Zeile 26, in
aus ._internal_utils in_native_string importieren
Datei "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", Zeile 11, in
aus .compat import is_py2, builtin_str, str
Datei "/usr/local/lib/python3.6/dist-packages/requests/compat.py", Zeile 59, in
von http import cookiejar als cookielib
Datei "/usr/lib/python3.6/http/cookiejar.py", Zeile 31, in
Kopie importieren
Datei "/copy.py", Zeile 2, in
aus Github importieren Github
ImportError: Name 'Github' kann nicht importiert werden

aus github.MainClass importieren Github
Traceback (letzter Anruf zuletzt):
Datei "", Zeile 1, in
Datei "/usr/local/lib/python3.6/dist-packages/github/__init__.py", Zeile 44, in
aus github.MainClass importieren Github, GithubIntegration
Datei "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", Zeile 58, in
Importanforderungen
Datei "/usr/local/lib/python3.6/dist-packages/requests/__init__.py", Zeile 112, in
von . Utils importieren
Datei "/usr/local/lib/python3.6/dist-packages/requests/utils.py", Zeile 26, in
aus ._internal_utils in_native_string importieren
Datei "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", Zeile 11, in
aus .compat import is_py2, builtin_str, str
Datei "/usr/local/lib/python3.6/dist-packages/requests/compat.py", Zeile 59, in
von http import cookiejar als cookielib
Datei "/usr/lib/python3.6/http/cookiejar.py", Zeile 31, in
Kopie importieren
Datei "/copy.py", Zeile 2, in
aus Github importieren Github
ImportError: Name 'Github' kann nicht importiert werden

Auf meinem Mac:

Github importieren
Traceback (letzter Anruf zuletzt):
Datei "", Zeile 1, in
Datei "/usr/local/lib/python3.7/site-packages/github/__init__.py", Zeile 44, in
aus github.MainClass importieren Github, GithubIntegration
Datei "/usr/local/lib/python3.7/site-packages/github/MainClass.py", Zeile 58, in
Importanforderungen
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", Zeile 112, in
von . Utils importieren
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", Zeile 26, in
aus ._internal_utils in_native_string importieren
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", Zeile 11, in
aus .compat import is_py2, builtin_str, str
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", Zeile 59, in
von http import cookiejar als cookielib
Datei "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", Zeile 31, in
Kopie importieren
Datei "/Users/amanda/copy.py", Zeile 2, in
aus Github importieren Github
ImportError: Name 'Github' kann nicht aus 'github' importiert werden (/usr/local/lib/python3.7/site-packages/github/__init__.py)

aus github.MainClass importieren Github
Traceback (letzter Anruf zuletzt):
Datei "", Zeile 1, in
Datei "/usr/local/lib/python3.7/site-packages/github/__init__.py", Zeile 44, in
aus github.MainClass importieren Github, GithubIntegration
Datei "/usr/local/lib/python3.7/site-packages/github/MainClass.py", Zeile 58, in
Importanforderungen
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", Zeile 112, in
von . Utils importieren
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", Zeile 26, in
aus ._internal_utils in_native_string importieren
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", Zeile 11, in
aus .compat import is_py2, builtin_str, str
Datei "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", Zeile 59, in
von http import cookiejar als cookielib
Datei "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", Zeile 31, in
Kopie importieren
Datei "/Users/amanda/copy.py", Zeile 2, in
aus Github importieren Github
ImportError: Name 'Github' kann nicht aus 'github' importiert werden (/usr/local/lib/python3.7/site-packages/github/__init__.py)

Ich sollte beachten, dass ich heute Morgen auf meiner Arbeitsmaschine bin und den Test vom Macbook aus mache
MacOS Mojave 10.14.6 mit installiertem Python 3.7.5. Für den Ubuntu-Container ist es dieselbe, dieselbe Version von 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 

Woher kommt diese Datei /copy.py oder /Users/amanada/copy.py? Es maskiert ein echtes Python-Modul /usr/lib/python3.6/copy.py und verursacht einen zirkulären Import.

copy.py ist ein Skript, an dem ich gearbeitet habe und das PyGithub verwendet. Als ich diese Befehle ausführte, wurden sie vom Python-Interpreter selbst ausgeführt, nachdem ich versucht hatte, das Skript auszuführen. Ich habe einen neuen Container hochgefahren, ohne dieses Skript auszuführen, und habe nur die Importbefehle über den Python-Interpreter ausgeführt und funktioniert einwandfrei:

Github importieren
aus Github importieren Github
Ausfahrt()

Ich bin mir nicht sicher, warum das Hinzufügen in mein Skript alles kaputt gemacht hat, es ist noch nicht einmal vollständig aufgebaut:

Shutil importieren
aus Github importieren Github

ACCESS_TOKEN = '123456789'

Initialisieren Sie den Github-Client

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

@stevenk

Es hat alles wegen des Namens kaputt gemacht - es maskiert ein Python-Modul namens 'copy', das sich in der Modulimportkette befindet, wenn Sie from github import Github ausführen. Nennen Sie Ihr Skript etwas anderes und es sollte gut funktionieren.

Ah okay, danke für die Klarheit @stevenk Ich schätze deine Zeit!

@ p3nda Ich freue mich zu helfen! Ich werde dieses Problem schließen. Wenn Sie weitere Probleme haben, können Sie gerne ein neues Problem eröffnen.

Kann mir jemand bei diesem Fehler helfen

Traceback (letzter Anruf zuletzt):
Datei "terra.py", Zeile 1, in
aus python_terraform importieren *
ImportError: Kein Modul mit dem Namen python_terraform

In meinem Fall wurde dieser Fehler aufgrund von Problemen mit meinem Python-Importpfad angezeigt.

Ich benutze Python 3.7.3:

$ python3 --version
Python 3.7.3

Und PyPI 20.2.3:

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

Ich habe PyGithub installiert:

$ 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)

Es kann jedoch nicht importiert werden:

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

In der Pip-Ausgabe haben wir gesehen, dass das Paket auf /usr/local/lib/python3.7/site-packages installiert wurde. Dieses Verzeichnis war jedoch __not__ in meinem Python-Importpfad:

$ 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']

Lösung 1: Addieren Sie zu PYTHONPATH

Eine Möglichkeit, dies zu lösen, besteht darin, das fehlende Verzeichnis in ~/.bashrc zu meinem PYTHONPATH hinzuzufügen:

# 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

Und Quelle der Datei:

$ . ~/.bashrc

Lösung 2: In einen vorhandenen Importpfad installieren

/Users/jhwill/Library/Python/3.7/lib/python/site-packages befindet sich bereits in meinem Systempfad. Wir können dieses Verzeichnis also mit dem Befehl pip3 für die Installation als Ziel festlegen:

$ 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
War diese Seite hilfreich?
0 / 5 - 0 Bewertungen