PyGitHub๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํ๋๋ฐ "ImportError : No module named github"๊ฐ ํ์๋ฉ๋๋ค.
์ค์ ์ฌ์ :
macOS v10.13.6
Python v3.7.0
pip v18.0๊ณผ ํจ๊ป ์ค์น
ํ์ฌ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ณ๊ฒฝํ๊ณ ๋ค์ ์๋ ํ์๊ฒ ์ต๋๊น?
์คํฌ๋ฆฝํธ๋ฅผ ๋ค๋ฅธ ๋๋ ํ ๋ฆฌ๋ก ์ฎ๊ธฐ๊ณ ๋ค์ ์๋ํ๋ค๋ ๋ป์ ๋๊น? ๊ทธ๊ฒ์ด ๋น์ ์ด ์๋ฏธํ๋ ๋ฐ๋ผ๋ฉด, ๋๋ ์๋ํ์ง๋ง ์๋ฌด๊ฒ๋ ๋ฐ๋์ง ์์์ต๋๋ค.
์คํฌ๋ฆฝํธ ์ด๋ฆ๋ "github"์ ๋๊น?
์๋์, Python ์คํฌ๋ฆฝํธ์ ์ด๋ฆ์ "github"๊ฐ ์๋๋๋ค.
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ํ ์ฌ์ฉํ์ง ์์๊ธฐ ๋๋ฌธ์ README.md
์ ๊ณต๋ ์ํ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํ์ต๋๋ค.
@JosephTLyons ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ $ pip install pygithub
๋ฅผ ์คํ ํ์ต๋๊น?
์ ๋๋ ํ์ด. ๋ค์ ์คํํ๋ฉด ํ์ธ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
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)
์๋
ํ์ธ์, @JosephTLyons MBP์ py2์ py3๋ฅผ ํจ๊ป ์ค์น ํ์ต๋๊น?
๊ทธ๋ ๋ค๋ฉด IDE ์ธํฐํ๋ฆฌํฐ ๊ตฌ์ฑ์ด pip ์ค์น์ ๋์ผํ ์ง ํ์ธํ์ญ์์ค.
์๋ ๊ทธ๋ฆผ์ฒ๋ผ
๋ด IDE ์ธํฐํ๋ฆฌํฐ ๊ตฌ์ฑ์
@JosephTLyons ํฐ๋ฏธ๋์์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ญ์์ค .... ์ฑ๊ณต์ ์ผ๋ก ์คํ๋๋ฉด IDE๊ฐ ์๋ชป ๊ตฌ์ฑ๋์์ต๋๋ค.
๋๋ python 2 (์ ํ์ด ๋งฅ๊ณผ ํจ๊ป ์ ๊ณต๋๋ ๋ฒ์ )์ python3 (Homebrew๋ฅผ ํตํด ์ค์น๋จ)์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
๋ํ ํฐ๋ฏธ๋์ ํตํด ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๊ณ ์์ผ๋ฉฐ IDE๋ฅผ ์ฌ์ฉํ์ง ์์ต๋๋ค. Atom์ผ๋ก ์๊ฒฉํ๊ฒ ์ฝ๋ฉํ๊ณ ํฐ๋ฏธ๋๋ก ์คํ ์ค์ ๋๋ค.
์ ๋ฅผ ์ฐธ์์ฃผ์ธ์. ์ ๋ ์๋ก์ด ํ๋ก๊ทธ๋๋จธ๋ ์๋์ง๋ง Python์ ์ฒ์ ์ ํ๊ณ ์ด๊ฒ์ ์ ๊ฐ ์ฌ์ฉํ๋ ค๊ณ ์๋ํ ์ฒซ ๋ฒ์งธ Python ๋ชจ๋ ์ค ํ๋์ด์ง๋ง ์ฑ๊ณตํ์ง ๋ชปํ์ต๋๋ค.
๋๋ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฐ์ง๊ณ ์๋ค. ๊ฐ์ ํ๊ฒฝ์ ๋ง๋ค๊ณ pip install PyGithub๋ฅผ ์ฌ์ฉํ์ฌ PyGithub๋ฅผ ์ค์นํ๋ ค๊ณ ํ์ต๋๋ค. ๋ฐ์ ๋ด์ฉ : ์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (--upgrade๋ฅผ ์ฌ์ฉํ์ฌ ์
๊ทธ๋ ์ด๋) : pygithub in /myvenv/lib/python3.5/site-packages
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด --upgrade ์ฌ์ฉ) : requests> = 2.14.0 in /myvenv/lib/python3.5/site-packages(from pygithub)
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ๋์์ต๋๋ค (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด --upgrade ์ฌ์ฉ) : /myvenv/lib/python3.5/site-packages์ pyjwt (pygithub์์)
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด -upgrade ์ฌ์ฉ) : idna <2.8,> = 2.5 in /myvenv/lib/python3.5/site-packages (from requests> = 2.14.0-> pygithub)
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด -upgrade ์ฌ์ฉ) : chardet <3.1.0,> = 3.0.2 in /myvenv/lib/python3.5/site-packages (from requests> = 2.14.0-> pygithub)
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด --upgrade ์ฌ์ฉ) : certifi> = 2017.4.17 in /myvenv/lib/python3.5/site-packages(from requests> = 2.14.0-> pygithub)
์๊ตฌ ์ฌํญ์ด ์ด๋ฏธ ์ถฉ์กฑ ๋จ (์
๊ทธ๋ ์ด๋ํ๋ ค๋ฉด -upgrade ์ฌ์ฉ) : urllib3 <1.24,> = 1.21.1 in /myvenv/lib/python3.5/site-packages (from requests> = 2.14.0-> pygithub)
ํฐ๋ฏธ๋์ ํตํด ํ์ด์ฌ์ ์ฌ์ฉํ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฐ์ ธ ์ค๊ธฐ๋ฅผ ์๋ํ์ง๋ง ... ์ฑ๊ณตํ์ง ๋ชปํ์ต๋๋ค.
Python 2 virtualenv๊ฐ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๊น?
์ฌ์ฉ๋๋ ๊ณณ์์๋ ์ถฉ๋๋ก ์ธํด Python 2๊ฐ ์ฌ์ฉ๋์ง ์์ต๋๋ค.
์ด๊ฒ์ ์ฑ๊ฐ์ ์๋ ค์ง ๋ฌธ์ ์ธ ๊ฒ ๊ฐ์ต๋๋ค. ์กฐ์ฌํ์ฌ ์์ ํด ๋ณด๊ฒ ์ต๋๋ค.
PIP์ ๋ฌธ์ ๊ฐ ๋ ์ ์์ต๋๊น?
Linux Mate์์ ๋ค๋ฅธ ๋ชจ๋๊ณผ ํจ๊ป์ด ๋ฌธ์ ๊ฐ ์์๋ ๊ฒ์ ๊ธฐ์ตํฉ๋๋ค.
์ด๊ฒ์ด ์ฌ์ ํ ๋ฌธ์ ์ธ ๊ฒฝ์ฐ ์ต์ ๋ง์คํฐ ๋ธ๋์น์์ pip๋ฅผ ์ค์นํ์ฌ de6b713b0์์ ๊ฐ์ ธ ์ค๊ธฐ ๋ฌธ์ ๋ฅผ ์์ ํ์ต๋๋ค.
๋ํ # 314์์๋ ๋๊ธ์ ํ์ธํด ๋ณผ ๊ฐ์น๊ฐ ์์ต๋๋ค.
๊ฐ์ ๋ฌธ์ .
๋ค์ ๋ช
๋ น์ผ๋ก pygithub๋ฅผ ์ค์นํ์ญ์์ค : python -m pip install pygithub
์ด๋ ๊ฒํ๋ฉด ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ python ์ธํฐํ๋ฆฌํฐ์ ๊ด๋ จ๋ pip๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋๋ ๊ทธ๊ฒ์ํ๋ค :
python3 -m venv myvenv
ํ๊ฒฝ์ ํ์ฑํ ํ ๋ค์ :
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.
pygithub๋ฅผ ์ฌ์ฉํ์ฌ ์คํฌ๋ฆฝํธ ์คํ์ ์๋ํ์ง๋ง ์ค๋ฅ๊ฐ ๋ฐํ๋์ง ์์์ต๋๋ค.
๊ฐ์ ํ๊ฒฝ์ ๋ช ๋ น ์ค์์ ๋จผ์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํ ํด ๋ณด๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ด๋ ์๋์ ์์ ๋๋ฌธ์ผ ์ ์์ต๋๋ค. Python 3์๋ ์ ๋ ๊ฐ์ ธ ์ค๊ธฐ๊ฐ ํ์ํฉ๋๋ค. ์ด๊ฒ์ # 967๋ก ์์ ๋์ด์ผํฉ๋๋ค.
sudo pip3 install pygithub
๊ฐ) ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค.
์ด๊ฒ์ ํ์ด์ฌ 3.7 ์ด์์์ ์ค๋จ๋์ง๋ง 3.6.5 FYI์์ ์๋ํฉ๋๋ค.
3.7.2๋ pip 18์ ์ฌ์ฉํ์ง๋ง 3.6.5๋ 9.x๋ฅผ ์ฌ์ฉํ๋ฏ๋ก pip ๋ฌธ์ ์ธ์ง ํ์คํ์ง ์์ต๋๋ค.
์ด๊ฒ์ ํ์ด์ฌ 3.7์์ ์ค๋จ๋ฉ๋๋ค.
๋์ํฉ๋๋ค. ๋ฐฉ๊ธ ํ ์คํธํ์ต๋๋ค. Python 3.7 ์ด์์ ์ฌ์ฉํ ๋ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
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'
Python 3.6์ ์ฌ์ฉํ๋ฉด ์ ์์ ์ผ๋ก ์๋ํฉ๋๋ค.
์ด๊ฒ์ Python 3.7์์ ์ฌ์ ํ ์๋ํ์ง ์์ต๋๊น? ๊ฐ์ ธ์ฌ ๋ ์ฌ์ ํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๊น?
@ conoroshea1996 ๊ทธ๋ค์ ๊ทธ๊ฒ์ ๊ณ ์น๊ธฐ ์ํด ์ฌ๋ฌ PR์๋ ๋ถ๊ตฌํ๊ณ ๊ณผ๊ฑฐ์ ์ด๊ฒ์ ๊ณ ์น๋ ๊ฒ์ ๊ฑฐ๋ถํ์ต๋๋ค.
Mac OS์์ Pycharm์ ์ฌ์ฉํ ๋๋ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง๋ง Mac OS์์ Jupyter๋ฅผ ์ฌ์ฉํ ๋๋์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ Windows์์ Pycharm ๋๋ Jupyter๋ฅผ ์ฌ์ฉํ ๋์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
+1
Python 3.7.4 ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
@ p3nda ์ด๊ฒ์ ์ด์ ์๋ณด๊ณ ๋ ๊ฒ๊ณผ ๊ฑฐ์ ๊ฐ์ ๋ฌธ์ ๊ฐ ์๋๋๋ค. ์ ์ฒด ์ค๋ฅ๋ฅผ ํ์ ํ ์ ์์ต๋๊น?
์๋
ํ์ธ์ @stevenk,
ํ์คํ ๊ฒ:
python3-๋ฒ์
ํ์ด์ฌ 3.7.4
๋๋ ์ป๋ค:
ImportError : 'github'(/ usr / local / lib / python3.7 / site-packages / github / __ init__.py)์์ 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
์ด ์ค๋ฅ๊ฐ ์ฝ๊ฐ ๋ค๋ฅด๋ค๊ณ ์๊ฐํ๊ธฐ ๋๋ฌธ์ ์ ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐ ํ ํ ๋์ปค ์ปจํ ์ด๋๋ฅผ ํ์ ์ํค๊ณ python3.6์ ์ค์นํ๊ณ ์ฌ์ฉํ๋ ค๊ณ ํ์ต๋๋ค.
ImportError : 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
python3-๋ฒ์
ํ์ด์ฌ 3.6.9
@ p3nda ์ด๋ค ํ๋ซํผ์์?
@stevenk python3.7.4์ ์ฒซ ๋ฒ์งธ ์ค๋ฅ๋ macos mojave 10.14.6์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. Python 3.6.9๋ฅผ ์ฌ์ฉํ๋ Docker ์ปจํ ์ด๋์์ Ubuntu 18.04.3์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
๊ทธ๋์ ์ด์ํฉ๋๋ค.
>>> 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'
์ค?
๊ทธ๋ฆฌ๊ณ from github.MainClass import Github
์ฃ์กํฉ๋๋ค
Ubuntu 18.04 Docker ์ปจํ ์ด๋ :
github ๊ฐ์ ธ ์ค๊ธฐ
์ญ ์ถ์ (๊ฐ์ฅ ์ต๊ทผ ํธ์ถ ๋ง์ง๋ง) :
ํ์ผ "", 1 ํ, in
ํ์ผ "/usr/local/lib/python3.6/dist-packages/github/__init__.py", 44 ํ
github.MainClass์์ ๊ฐ์ ธ ์ค๊ธฐ Github, GithubIntegration
ํ์ผ "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", 58 ํ
์์ ์์ฒญ
"/usr/local/lib/python3.6/dist-packages/requests/__init__.py"ํ์ผ, 112 ํ
์์. ์์ ์ ํธ๋ฆฌํฐ
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/utils.py", 26 ํ,
._internal_utils์์ ๊ฐ์ ธ ์ค๊ธฐ to_native_string
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", 11 ํ,
.compat์์ ๊ฐ์ ธ ์ค๊ธฐ is_py2, builtin_str, str
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/compat.py", 59 ํ,
http import cookiejar์์ cookielib๋ก
ํ์ผ "/usr/lib/python3.6/http/cookiejar.py", 31 ํ,
์์ ์ฌ๋ณธ
ํ์ผ "/copy.py", 2 ํ,
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
ImportError : 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
github.MainClass์์ Github ๊ฐ์ ธ ์ค๊ธฐ
์ญ ์ถ์ (๊ฐ์ฅ ์ต๊ทผ ํธ์ถ ๋ง์ง๋ง) :
ํ์ผ "", 1 ํ, in
ํ์ผ "/usr/local/lib/python3.6/dist-packages/github/__init__.py", 44 ํ
github.MainClass์์ ๊ฐ์ ธ ์ค๊ธฐ Github, GithubIntegration
ํ์ผ "/usr/local/lib/python3.6/dist-packages/github/MainClass.py", 58 ํ
์์ ์์ฒญ
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/__init__.py", 112 ํ
์์. ์์ ์ ํธ๋ฆฌํฐ
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/utils.py", 26 ํ,
._internal_utils์์ ๊ฐ์ ธ ์ค๊ธฐ to_native_string
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/_internal_utils.py", 11 ํ,
.compat์์ ๊ฐ์ ธ ์ค๊ธฐ is_py2, builtin_str, str
ํ์ผ "/usr/local/lib/python3.6/dist-packages/requests/compat.py", 59 ํ
http import cookiejar์์ cookielib๋ก
ํ์ผ "/usr/lib/python3.6/http/cookiejar.py", 31 ํ,
์์ ์ฌ๋ณธ
ํ์ผ "/copy.py", 2 ํ,
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
ImportError : 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
๋ด Mac์์ :
github ๊ฐ์ ธ ์ค๊ธฐ
์ญ ์ถ์ (๊ฐ์ฅ ์ต๊ทผ ํธ์ถ ๋ง์ง๋ง) :
ํ์ผ "", 1 ํ, in
ํ์ผ "/usr/local/lib/python3.7/site-packages/github/__init__.py", 44 ํ
github.MainClass์์ ๊ฐ์ ธ ์ค๊ธฐ Github, GithubIntegration
ํ์ผ "/usr/local/lib/python3.7/site-packages/github/MainClass.py", 58 ํ,
์์ ์์ฒญ
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", 112 ํ
์์. ์์ ์ ํธ๋ฆฌํฐ
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", 26 ํ,
._internal_utils์์ ๊ฐ์ ธ ์ค๊ธฐ to_native_string
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", 11 ํ
.compat์์ ๊ฐ์ ธ ์ค๊ธฐ is_py2, builtin_str, str
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", 59 ํ
http import cookiejar์์ cookielib๋ก
ํ์ผ "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", 31 ํ,
์์ ์ฌ๋ณธ
ํ์ผ "/Users/amanda/copy.py", 2 ํ,
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
ImportError : 'github'(/ usr / local / lib / python3.7 / site-packages / github / __ init__.py)์์ 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
github.MainClass์์ Github ๊ฐ์ ธ ์ค๊ธฐ
์ญ ์ถ์ (๊ฐ์ฅ ์ต๊ทผ ํธ์ถ ๋ง์ง๋ง) :
ํ์ผ "", 1 ํ, in
ํ์ผ "/usr/local/lib/python3.7/site-packages/github/__init__.py", 44 ํ
github.MainClass์์ ๊ฐ์ ธ ์ค๊ธฐ Github, GithubIntegration
ํ์ผ "/usr/local/lib/python3.7/site-packages/github/MainClass.py", 58 ํ
์์ ์์ฒญ
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/__init__.py", 112 ํ
์์. ์์ ์ ํธ๋ฆฌํฐ
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/utils.py", 26 ํ,
._internal_utils์์ ๊ฐ์ ธ ์ค๊ธฐ to_native_string
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/_internal_utils.py", 11 ํ
.compat์์ ๊ฐ์ ธ ์ค๊ธฐ is_py2, builtin_str, str
ํ์ผ "/Users/amanda/Library/Python/3.7/lib/python/site-packages/requests/compat.py", 59 ํ
http import cookiejar์์ cookielib๋ก
ํ์ผ "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/cookiejar.py", 31 ํ,
์์ ์ฌ๋ณธ
ํ์ผ "/Users/amanda/copy.py", 2 ํ,
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
ImportError : 'github'(/ usr / local / lib / python3.7 / site-packages / github / __ init__.py)์์ 'Github'์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
๋๋ ์ค๋ ์์นจ์ ๋งฅ๋ถ์์ ํ
์คํธ๋ฅผํ๊ณ ์๋ ๋ด ์์
๊ธฐ๊ณ์ ์๋ค๋ ๊ฒ์ ์์์ผํ๋ค.
Python 3.7.5๊ฐ ์ค์น๋ MacOS Mojave 10.14.6. ์ฐ๋ถํฌ ์ปจํ
์ด๋์ ๊ฒฝ์ฐ ๋์ผํ ๋ฒ์ ์ Python์
๋๋ค.
ํ
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
/copy.py ๋๋ /Users/amanada/copy.py ํ์ผ์ ์ถ์ฒ๋ ์ด๋์ ๋๊น? ์ค์ Python ๋ชจ๋ /usr/lib/python3.6/copy.py๋ฅผ ๋ง์คํนํ๊ณ ์ํ ๊ฐ์ ธ ์ค๊ธฐ๋ฅผ ๋ฐ์์ํต๋๋ค.
copy.py๋ PyGithub๋ฅผ ์ฌ์ฉํ๋ ์คํฌ๋ฆฝํธ์ ๋๋ค. ์ด ๋ช ๋ น์ ์คํํ์ ๋ ์คํฌ๋ฆฝํธ ์คํ์ ์๋ํ ํ ํ์ด์ฌ ์ธํฐํ๋ฆฌํฐ ์์ฒด์์ ์คํ๋์์ต๋๋ค. ํด๋น ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ง ์๊ณ ์ ์ปจํ ์ด๋๋ฅผ ํ์ ํ๊ณ Python ์ธํฐํ๋ฆฌํฐ๋ฅผ ํตํด ๊ฐ์ ธ ์ค๊ธฐ ๋ช ๋ น์ ์คํํ๊ณ ์ ์์ ์ผ๋ก ์๋ํฉ๋๋ค.
github ๊ฐ์ ธ ์ค๊ธฐ
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
์ถ๊ตฌ()
๋ด ์คํฌ๋ฆฝํธ์ ์ถ๊ฐํ๋ฉด ์ ๋ชจ๋ ๊ฒ์ด ๋ง๊ฐ ์ก๋์ง ๋ชจ๋ฅด๊ฒ ์ง๋ง ์์ง ์์ ํ ํ์ฑ๋์ง ์์์ต๋๋ค.
์์
Shutil
github์์ ๊ฐ์ ธ ์ค๊ธฐ Github
ACCESS_TOKEN = '123456789'
g = Github (ACCESS_TOKEN)
print (g.get_user (). get_repos ())
ํ
์ด๋ฆ ๋๋ฌธ์ ๋ชจ๋ ๊ฒ์ด ๊นจ์ก์ต๋๋ค. from github import Github
๋ฅผ ์คํํ ๋ ๋ชจ๋ ๊ฐ์ ธ ์ค๊ธฐ ์ฒด์ธ์์๋ 'copy'๋ผ๋ Python ๋ชจ๋์ ๋ง์คํนํฉ๋๋ค. ์คํฌ๋ฆฝํธ๋ฅผ ๋ค๋ฅธ ๊ฒ์ผ๋ก ๋ถ๋ฅด๋ฉด ์ ๋๋ก ์๋ํฉ๋๋ค.
์ ์ข์์, @stevenk์ ๋ช ํ์ฑ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์๊ฐ์ ๋ด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
@ p3nda ๋์ ๋๋ฆฌ๊ฒ ์ต๋๋ค! ์ด ๋ฌธ์ ๋ฅผ ์ข ๋ฃํ๊ฒ ์ต๋๋ค. ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ์์ผ๋ฉด ์ธ์ ๋ ์ง ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์.
๋๊ตฐ๊ฐ์ด ์ค๋ฅ๋ก ๋๋ฅผ ๋์ธ ์ ์์ต๋๊น?
์ญ ์ถ์ (๊ฐ์ฅ ์ต๊ทผ ํธ์ถ ๋ง์ง๋ง) :
ํ์ผ "terra.py", ์ค 1, in
python_terraform ๊ฐ์ ธ ์ค๊ธฐ์์ *
ImportError : python_terraform์ด๋ผ๋ ๋ชจ๋์ด ์์ต๋๋ค.
์ ๊ฒฝ์ฐ์๋ Python ๊ฐ์ ธ ์ค๊ธฐ ๊ฒฝ๋ก ๋ฌธ์ ๋ก ์ธํด์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
Python 3.7.3์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
$ python3 --version
Python 3.7.3
๊ทธ๋ฆฌ๊ณ PyPI 20.2.3 :
$ pip3 --version
pip 20.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
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)
๊ทธ๋ฌ๋ ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ๊ฐ์ ธ ์ค์ง ๋ชปํ์ต๋๋ค.
$ python3 <<< "from github import Github"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'github'
pip ์ถ๋ ฅ์์ โโํจํค์ง๊ฐ /usr/local/lib/python3.7/site-packages
์ ์ค์น๋์์์ ํ์ธํ์ต๋๋ค. ๊ทธ๋ฌ๋์ด ๋๋ ํ ๋ฆฌ๋ ๋ด Python ๊ฐ์ ธ ์ค๊ธฐ ๊ฒฝ๋ก์์ __not__์ด์์ต๋๋ค.
$ 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']
PYTHONPATH
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ํ ๊ฐ์ง ๋ฐฉ๋ฒ์ ~/.bashrc
PYTHONPATH
๋๋ฝ ๋ ๋๋ ํ ๋ฆฌ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์
๋๋ค.
# 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
๊ทธ๋ฆฌ๊ณ ํ์ผ ์์ค :
$ . ~/.bashrc
/Users/jhwill/Library/Python/3.7/lib/python/site-packages
์ด (๊ฐ) ์ด๋ฏธ ๋ด ์์คํ
๊ฒฝ๋ก์ ์์ต๋๋ค. ๋ฐ๋ผ์ 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
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋์ํฉ๋๋ค. ๋ฐฉ๊ธ ํ ์คํธํ์ต๋๋ค. Python 3.7 ์ด์์ ์ฌ์ฉํ ๋ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
Python 3.6์ ์ฌ์ฉํ๋ฉด ์ ์์ ์ผ๋ก ์๋ํฉ๋๋ค.