Pip: SSL: Python 3.6.0์—์„œ CERTIFICATE_VERIFY_FAILED

์— ๋งŒ๋“  2016๋…„ 12์›” 24์ผ  ยท  23์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: pypa/pip

  • ํ• ๋ฒ„์ „: 9.0.1
  • ํŒŒ์ด์ฌ ๋ฒ„์ „: 3.6.0
  • ์šด์˜ ์ฒด์ œ: macOS ์‹œ์—๋ผ

์„ค๋ช…:

pip install -U channels ๋ฅผ ์‹คํ–‰ํ•  ๋•Œ pypi.python.org ์— ๋Œ€ํ•œ ์ธ์ฆ์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ œ๊ฐ€ pip ๋˜๋Š” Python 3.6.0 ๋˜๋Š” ๋‹ค๋ฅธ ๊ฒƒ๊ณผ ๊ด€๋ จ๋œ ๊ฒƒ์ธ์ง€ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์ œ์•ˆ์„ ์‹œ๋„ํ–ˆ์ง€๋งŒ ๊ทธ ์ค‘ ์•„๋ฌด ๊ฒƒ๋„ ํšจ๊ณผ๊ฐ€ ์—†์—ˆ์Šต๋‹ˆ๋‹ค.

pip --trusted-host pypi.python.org install -U channels

export PIP_CERT=/Users/user/Desktop/certificate_which_i_obtained_from_pypi_dot_python_dot_org.crt
pip install -U channels

๋‹ค์Œ cacert.pem ์€ curl ์˜ ์ธ์ฆ์„œ์ž…๋‹ˆ๋‹ค.
pip --cert /Users/user/cacert.pem install -U channels

๋˜ํ•œ ์ด ๋ฌธ์ œ๊ฐ€ Python 3.6.0๊ณผ ๊ด€๋ จ์ด ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์ถœ๋ ฅ์„ ๊ณ ๋ คํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

user<strong i="25">@host</strong>:~$ python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> context = ssl.create_default_context()
>>> context.cert_store_stats()
{'x509': 0, 'crl': 0, 'x509_ca': 0}
>>> context.get_ca_certs()
[]
>>> 

๋‚ด๊ฐ€ ์‹คํ–‰ํ•œ ๊ฒƒ:

(virtualenv) user<strong i="29">@host</strong>:~/Documents/virtualenv$ pip install -U channels
Collecting channels
  Using cached channels-0.17.3-py2.py3-none-any.whl
Collecting asgiref>=0.13 (from channels)
  Using cached asgiref-1.0.0-py2.py3-none-any.whl
Collecting daphne>=0.14.1 (from channels)
  Using cached daphne-0.15.0-py2.py3-none-any.whl
Requirement already up-to-date: Django>=1.8 in ./lib/python3.6/site-packages (from channels)
Collecting six (from asgiref>=0.13->channels)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting twisted>=16.0 (from daphne>=0.14.1->channels)
  Using cached Twisted-16.6.0.tar.bz2
    Complete output from command python setup.py egg_info:
    Download error on https://pypi.python.org/simple/incremental/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
    Couldn't find index page for 'incremental' (maybe misspelled?)
    Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
    No local packages or working download links found for incremental>=16.10.1
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/45/r4yr9bbj29dfbtxqv75_785m0000gn/T/pip-build-02d49zb3/twisted/setup.py", line 21, in <module>
        setuptools.setup(**_setup["getSetupArgs"]())
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/setuptools/dist.py", line 316, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/setuptools/dist.py", line 371, in fetch_build_eggs
        replace_conflicting=True,
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 846, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1118, in best_match
        return self.obtain(req, installer)
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1130, in obtain
        return installer(requirement)
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/setuptools/dist.py", line 439, in fetch_build_egg
        return cmd.easy_install(req)
      File "/Users/user/Documents/virtualenv/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 668, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('incremental>=16.10.1')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/45/r4yr9bbj29dfbtxqv75_785m0000gn/T/pip-build-02d49zb3/twisted/
(virtualenv) user<strong i="30">@host</strong>:~/Documents/virtualenv$ 

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

get-pip.py๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ ๋ฒ„์ „์˜ pip๋ฅผ ์ง์ ‘ ์„ค์น˜ํ•ด ๋ณด์‹ญ์‹œ์˜ค(https://pip.pypa.io/en/stable/installing/ ์ฐธ์กฐ).

$ curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
$ sudo python get-pip.py

(@pradyunsg ํ˜•์‹)

๋ชจ๋“  23 ๋Œ“๊ธ€

๋‚˜๋„์ด ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค.

๋ฌธ์ œ๋Š” Python 3.6.0์„ ๋นŒ๋“œํ•  ๋•Œ ssl ๋ชจ๋“ˆ์ด ํ™œ์„ฑํ™”๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Python-3.6.0/Modules/Setup์—์„œ 209-212 ํ–‰์˜ ์ฃผ์„ ์ฒ˜๋ฆฌ๋ฅผ ์ œ๊ฑฐํ•˜์—ฌ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

SSL=/usr/local/ssl
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

libssl-dev ๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค(์–ด์จŒ๋“  ์ด๊ฒƒ์€ ๋ฐ๋น„์•ˆ์šฉ ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค).

์™„๋ฃŒ๋˜๋ฉด ./configure , make ๋ฐ make install ๋ฅผ ๋‹ค์‹œ ์ˆ˜ํ–‰ํ•˜๋ฉด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

Python 3.5, ์ตœ์‹  OSX์—์„œ ๋˜‘๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

$ pip install pip --upgrade
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720) - skipping

์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ํ˜ธ์ŠคํŠธ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

$ pip install --trusted-host pypi.python.org pip --upgrade
Requirement already up-to-date: pip in ./venv/lib/python3.5/site-packages

๋‚˜๋Š” --trusted-host ๋ฅผ ์ˆ˜์ •์ด๋ผ๊ณ  ๋ถ€๋ฅด์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ธฐ๊ปํ•ด์•ผ ์œ„ํ—˜ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. TLS ํ™•์ธ์„ ๋น„ํ™œ์„ฑํ™”ํ•˜๊ณ  ์ปดํ“จํ„ฐ๋ฅผ ๋ฉ”์‹œ์ง€ ๊ฐ€๋กœ์ฑ„๊ธฐ ๊ณต๊ฒฉ์— ๋…ธ์ถœ์‹œํ‚ต๋‹ˆ๋‹ค. ์˜ต์…˜์€ --bypass-insecure-host ๋˜๋Š” ์ด์™€ ์œ ์‚ฌํ•œ ์ด๋ฆ„์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์„œ ๋ฌธ์ œ๋Š” setuptools๊ฐ€ pip๊ฐ€ ์•„๋‹Œ PyPI์™€ ํ†ต์‹ ํ•˜๋ ค๊ณ  ํ•˜๊ณ  macOS์˜ 3.6.0์€ ๊ธฐ๋ณธ์ ์œผ๋กœ CA ๋ฒˆ๋“ค์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์—†์œผ๋ฉฐ setuptools๋Š” pip์ฒ˜๋Ÿผ ๋ฒˆ๋“ค์„ ๋ฒˆ๋“คํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. certifi์™€ ๊ฐ™์€ ๊ฒƒ์„ ์„ค์น˜ํ•˜๊ฑฐ๋‚˜ setuptools์— ๋ฌธ์ œ๋ฅผ ์ œ๊ธฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

ํ• ์„ค์น˜ ์ฆ๋ถ„

๋‹น์‹ ์€ ์˜์›… ์ž…๋‹ˆ๋‹ค @CallenChen

๊ทธ๋ž˜๋„ ์•ˆ๋˜๋„ค์š” ๋„์™€์ฃผ์„ธ์š”...

C:\Windows\system32>pip ์„ค์น˜ ์ฆ๋ถ„
์ฆ๋ถ„ ์ˆ˜์ง‘
URL https://pypi.python.org/simple/incremental/์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: SSL ์ธ์ฆ์„œ๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค: [SSL: CERTIFICATE_VERIFY_FAILED] ์ธ์ฆ์„œ ํ™•์ธ ์‹คํŒจ(_ssl.c:748) - ๊ฑด๋„ˆ๋›ฐ๊ธฐ
์ฆ๋ถ„ ์š”๊ตฌ ์‚ฌํ•ญ์„ ์ถฉ์กฑํ•˜๋Š” ๋ฒ„์ „์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค(๋ฒ„์ „: ).
์ฆ๋ถ„์— ๋Œ€ํ•ด ์ผ์น˜ํ•˜๋Š” ๋ถ„ํฌ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

OSX์—์„œ macport๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ curl-ca-bundle์„ ์„ค์น˜ํ•˜๋ฉด ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

sudo ํฌํŠธ ์„ค์น˜ curl-ca-bundle

์–‘์กฐ ์—…๋ฐ์ดํŠธ
์–‘์กฐ ์ œ๊ฑฐ openssl
์–‘์กฐ ์„ค์น˜ openssl
echo '๋‚ด๋ณด๋‚ด๊ธฐ PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

์—ฌ๊ธฐ์— ์–ธ๊ธ‰๋œ ๋Œ€๋กœ certifi๋ฅผ ์„ค์น˜ํ•˜๋Š”

pip install certifi

@gitanupam ์ธ์ฆ์„œ ์„ค์น˜๊ฐ€ ์ €์—๊ฒŒ ํšจ๊ณผ์ ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

์–ด๋–ค ์†”๋ฃจ์…˜๋„ ๋‚˜๋ฅผ ์œ„ํ•ด ์ผํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๋‚˜๋Š” OSX์—์žˆ์–ด

get-pip.py๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ ๋ฒ„์ „์˜ pip๋ฅผ ์ง์ ‘ ์„ค์น˜ํ•ด ๋ณด์‹ญ์‹œ์˜ค(https://pip.pypa.io/en/stable/installing/ ์ฐธ์กฐ).

$ curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
$ sudo python get-pip.py

(@pradyunsg ํ˜•์‹)

@ sdk21 ์ด๊ฒƒ์€ ์ €์—๊ฒŒ ํšจ๊ณผ์ ์ž…๋‹ˆ๋‹ค. ๊ณ ๋งˆ์›Œ

์ด์œ ๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ Pypi๊ฐ€ ๋” ์ด์ƒ http ์—ฐ๊ฒฐ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฏธ๋Ÿฌ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ฉด ์ €์—๊ฒŒ ํšจ๊ณผ์ ์ž…๋‹ˆ๋‹ค.

$ cat ~/.config/pip/pip.conf
[global]
proxy = http://my-proxy:8080
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

PyPI๋Š” HTTP ์—ฐ๊ฒฐ์„ ์ˆ˜๋ฝํ•˜์ง€๋งŒ ์ตœ๊ทผ์— TLS v1.0 ๋ฐ v1.1์— ๋Œ€ํ•œ ์ง€์›์„ ์ค‘๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค. https://stackoverflow.com/a/49769015/1526703 ์ฐธ์กฐ

์„ค๋ช… ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค, @gitanupam

@sdk21 ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ๊ทธ๊ฒƒ์€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค!

@ sdk21 ์ด๊ฒƒ์€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์‚ฌ ํ•ด์š”!

@ sdk21 ์ด๊ฒƒ์€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์‚ฌ ํ•ด์š”!

@dk21๋‹˜ ๋•๋ถ„์— ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค...

Mac์—์„œ ๋‚˜๋Š” ์ด๊ฒƒ์„ํ–ˆ๊ณ  ๋งˆ์นจ๋‚ด ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.
https://pip.readthedocs.io/en/stable/installing/

@sdk21 ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๐Ÿ‘

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰