program tip

인증 프록시 뒤의 Windows에서 pip를 사용하는 방법

radiobox 2020. 10. 18. 09:13
반응형

인증 프록시 뒤의 Windows에서 pip를 사용하는 방법


내 컴퓨터는 Windows 서버의 프록시 뒤에서 창을 실행 중이며 (활성 디렉토리 사용) pip(python3에서) 그것을 통해 얻는 방법을 알 수 없습니다 . 을 사용해 보았지만 --proxy여전히 시간 초과입니다. 또한 긴 시간 제한 (60 초)을 설정해 보았지만 아무런 차이가 없었습니다. 내 프록시 설정이 올 바르고 TortoiseHG에서 성공적으로 사용중인 프록시 설정과 비교하여 확인했습니다.

누구든지 내가 시도 할 수있는 다른 트릭이 있습니까, 아니면 pipWindows 프록시와 관련하여 제한이 있습니까?

업데이트 : 실패한 시도는 pypi 검색과 ​​관련이 있습니다. 나는 실제로 무언가를 설치하려고 시도했지만 작동했습니다. 그래도 검색이 실패합니다. 버그가 있음을 나타내 pip거나 다르게 작동합니까?


회사의 NTLM 인증 프록시에서 작동하는 두 가지 옵션을 시도했습니다. 옵션 1은--proxy http://user:pass@proxyAddress:proxyPort

여전히 문제가있는 경우 프록시 인증 서비스 ( CNTLM 사용 )를 설치하고 pip를 가리키는 것이 좋습니다.--proxy http://localhost:3128


이것을 알아내는 데 몇 시간이 걸렸지 만 마침내 CNTLM을 사용하여 작동하고 나중에 pip 구성 파일로만 작동하도록했습니다. 다음은 pip 구성 파일로 작업하는 방법입니다.

해결책:

1. Windows에서 사용자 프로필 디렉터리 (예 : C : \ Users \ Sync)로 이동하여 " pip " 라는 폴더를 만듭니다.

2. 이 디렉터리 (예 : C : \ Users \ Sync \ pip \ pip.ini)에 " pip.ini " 라는 파일을 만들고 다음을 입력합니다.

    [global]
    trusted-host = pypi.python.org
                   pypi.org
                   files.pythonhosted.org
    proxy = http://[domain name]%5C[username]:[password]@[proxy address]:[proxy port]

[도메인 이름] , [사용자 이름] , [비밀번호] , [프록시 주소][프록시 포트] 를 자신의 정보로 바꿉니다 .

3. 이 시점에서 아무런 문제없이 " pip install " 을 실행할 수있었습니다 .

바라건대 이것은 다른 사람들에게도 효과가 있습니다!

추신 : 암호를 일반 텍스트로 저장하기 때문에 보안 문제가 발생할 수 있습니다. 이것이 문제인 경우이 문서를 사용하여 CNTLM을 설정하는 것이 좋습니다 (일반 텍스트 대신 해시 된 암호 사용 허용). 나중에 proxy = 127.0.0.1:3128위에서 언급 한 "pip.ini"파일에서 설정 합니다.


이것이 내가 설정하는 방법입니다.

  1. 관리자 권한으로 명령 프롬프트 (CMD)를 엽니 다.
  2. 프록시 설정 내보내기 :

    set http_proxy=http://username:password@proxyAddress:port

    set https_proxy=https://username:password@proxyAddress:port

  3. 설치할 패키지를 설치하십시오.

    pip install PackageName

예를 들면 :

예


Windows 7에서 동일한 문제가 발생했습니다. 내부에 "pip.ini"파일이있는 "pip"폴더를 만들어 작동하도록 관리했습니다. Python 문서에 따르면이 폴더를 "C : \ Users \ {my.username} \ AppData \ Roaming"에 넣었습니다.

Windows에서 구성 파일은 % APPDATA % \ pip \ pip.ini입니다.

pip.ini 파일에는 다음 만 있습니다.

[global]
proxy = [proxy address]:[proxy port]

따라서 사용자 이름 : 암호가 없습니다. 그리고 그것은 잘 작동합니다.


비슷한 문제가 있었는데 회사에서 NTLM 프록시 인증을 사용한다는 사실을 알게되었습니다. pip.log에이 오류가 표시되면 다음과 같은 문제 일 수 있습니다.

URL http://pypi.python.org/simple/pyreadline을 가져올 수 없습니다 . HTTP 오류 407 : 프록시 인증 필요 (ISA Server에 요청을 수행하려면 인증이 필요합니다. 웹 프록시 필터에 대한 액세스가 거부되었습니다.)

NTLMap은 중간 프록시가되어 NTLM 프록시 서버와 인터페이스하는 데 사용할 수 있습니다.

NTLMAP를 다운로드하고 포함 된 server.cfg를 업데이트하고 main.py 파일을 실행 한 다음 pip의 프록시 설정을 127.0.0.1 :로 지정합니다.

또한 server.cfg파일 에서 이러한 기본값을 다음과 같이 변경해야 합니다.

LM_PART:1
NT_PART:1

# Highly experimental option. See research.txt for details.
# LM - 06820000
# NT - 05820000
# LM + NT - 
NTLM_FLAGS: 07820000

http://ntlmaps.sourceforge.net/


You may also run into problems with certificates from your proxy. There are plenty of answers here on how to retrieve your proxy's certificate.

On a Windows host, to allow pip to clear your proxy, you may want to set an environment variable such as:

PIP_CERT=C:\path\to\certificate\file\in\pem\form\myproxycert.pem

You can also use the --cert argument to PIP with the same result.


install cntlm: Cntlm: Fast NTLM Authentication Proxy in C

Config cntlm.ini:

Username ob66759

Domain NAM

Password secret

Proxy proxy1.net:8080

Proxy proxy2.net:8080

NoProxy localhost, 127.0.0.*, 10.*, 192.168.*

Listen 3128

Allow 127.0.0.1

#your IP

Allow 10.106.18.138

start it:

cntlm -v -c cntlm.ini

Now in cmd.exe:

pip install --upgrade pip --proxy 127.0.0.1:3128

Collecting pip
  Downloading https://files.pythonhosted.
44c8a6e917c1820365cbebcb6a8974d1cd045ab4/

    100% |███████████████████████████████
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1

Successfully installed pip-10.0.1

works!

You can also hide password: https://stormpoopersmith.com/2012/03/20/using-applications-behind-a-corporate-proxy/


same issue on windows10 and above solutions are not working for me.

use a emulator console tool like cygwin and then do it the default linux way:

export http_proxy=<proxy>
export https_proxy=<proxy>
pip install <package>

and things are working fine.


I had the same issue on a remote windows environment. I tried many solutions found here or on other similars posts but nothing worked. Finally, the solution was quite simple. I had to set NO_PROXY with cmd :

set NO_PROXY="<domain>\<username>:<password>@<host>:<port>"
pip install <packagename>

You have to use double quotes and set NO_PROXY to upper case. You can also add NO_PROXY as an environment variable instead of setting it each time you use the console.

I hope this will help if any other solution posted here works.


In my case it worked when I opened command prompt (cmd) as an administrator only and no further information about proxy settings was needed.

참고 URL : https://stackoverflow.com/questions/9698557/how-to-use-pip-on-windows-behind-an-authenticating-proxy

반응형