Urllib3 socks5 proxy error: 'socks' has no attribute 'create_connection' - python

I need Robobrowser to use Tor, easiest way i thought would be like this: Robobrowser with Sessions.
But i encountered a strange problem with requests, or more specific urllib3:
AttributeError: module 'socks' has no attribute 'create_connection'
As documented in Urllib3 Documentation create_connection is an attribute from socks.
Urllib3 version: 1.19.1
Requests version: 2.12.4
PySocks version: 1.6.5
import requests
session = requests.Session()
session.proxies = {'http':'socks5://127.0.0.1:9050'}
response = session.get('http://www.icanhazip.com', timeout=2)
print(response.text)
edit:
Stacktrace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 361, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connection.py", line 163, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/contrib/socks.py", line 79, in _new_conn
conn = socks.create_connection(
AttributeError: module 'socks' has no attribute 'create_connection'

It is because your python instance can't find the required socks libraries.
The libraries in /usr/lib/python* are installed via sudo apt-get install python3-requests etc.
However apt-get can't install the required pysocks libraries that the urllib3 uses. sudo apt-get install python3-socks won't work.
What will work is if you install it via sudo -H pip3 install pysocks urllib3[socks] requests[socks]
This will install it under here sudo ls -lrtah /usr/local/lib/python*/dist-packages/
Make sure you terminal session has /usr/lib:/usr/local/lib in the system path. If your python instance still can't find your socks library, then make sure both paths are part of your ~/.bashrc PYTHON_PATH export.

Related

ERROR:ddtrace.internal.writer:failed to send traces to Datadog Agent at http://localhost:8126: OSError: [Errno 99] Cannot assign requested address

I want to set up the datadog agent to monitor my python application running inside a docker container. I have created the docker image tagged as datadog_app:v_1.
Below is my docker file:
FROM ubuntu:18.04
WORKDIR /app
RUN apt-get update --no-install-recommends
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3-setuptools --no-install-recommends
RUN pip3 install Cython
RUN pip3 install ddtrace
RUN apt-get install -y curl
ADD ./datadog_app.py /app/handler.py
RUN DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=my_api_key DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"
CMD ddtrace-run python3 handler.py
Below is the code for the datadog_app.py file:
from ddtrace import tracer
import time
#tracer.wrap(service="addition")
def handler():
time.sleep(2)
print(1+2)
handler()
Now, I am trying to run a docker container from the "datadog_app:v_1: image in interactive and making sure to expose the port 8126 way by using the following command:
docker run -it -p 8126:8126 datadog_app:v_1
I am getting the following error:
ERROR:ddtrace.internal.writer:failed to send traces to Datadog Agent at http://localhost:8126
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tenacity/__init__.py", line 407, in __call__
result = fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/ddtrace/internal/writer.py", line 356, in _send_payload
response = self._put(payload, headers)
File "/usr/local/lib/python3.6/dist-packages/ddtrace/internal/writer.py", line 332, in _put
conn.request("PUT", self._endpoint, data, headers)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 980, in send
self.connect()
File "/usr/lib/python3.6/http/client.py", line 952, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/ddtrace/internal/writer.py", line 458, in flush_queue
self._retry_upload(self._send_payload, encoded, n_traces)
File "/usr/local/lib/python3.6/dist-packages/tenacity/__init__.py", line 404, in __call__
do = self.iter(retry_state=retry_state)
File "/usr/local/lib/python3.6/dist-packages/tenacity/__init__.py", line 361, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x7f32383f0a58 state=finished raised OSError>]
I have also tried running the following command:
docker run -it --expose=8126 datadog_app:v_1
But I am getting the same error.
My goal is to run the datadog-agent inside the same container that contains my python application. Can someone explain what is wrong with my code or my run commands?

python openssl: how to upgrade the openssl version while installing plugin in blender

I have this plugin which I want to install, but somehow the installation always breaks due to the error:
urllib.error.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)>
So I think the problem is maybe that the SSL version is too old, so I printed the version information out:
OpenSSL 0.9.8zh 14 Jan 2016
And after seeing some answers,enter link description here, enter link description here, enter link description here now I have the newest SSL on my mac, but it seems like this plugin is using some external python which is not installed on my disk, and this python always tries to use its own SSL. I found this python which blender uses, Show Package Contents -> Burrow down to Contents -> Resources -> 2.79 -> python, seems like it's python 3.5, and I have python 3.7 installed on the disk.
Here's the installation code of the plugin:
import bpy
import os
import addon_utils
from subprocess import call
from urllib.request import urlretrieve
from zipfile import ZipFile
from tempfile import TemporaryDirectory
from shutil import copytree,rmtree
from os.path import join
python_exec = bpy.app.binary_path_python
path_to_addons = bpy.utils.user_resource('SCRIPTS', "addons")
print('Install Pip')
try:
import pip
except:
rc = call([python_exec,"-m","ensurepip","--default-pip", "--upgrade"])
import pip
print('Download RD')
import ssl
print(ssl.OPENSSL_VERSION)
URL = "https://github.com/HBPNeurorobotics/BlenderRobotDesigner/archive/master.zip"
addon_dir = 'robot_designer_plugin'
zip_dir = "BlenderRobotDesigner-master"
print('Unzip RD')
with TemporaryDirectory() as tmp:
zip_file = join(tmp,"master.zip")
print(zip_file)
urlretrieve(URL,zip_file)
print('Downloaded!')
rc = call([python_exec,"-m","zipfile","-e",zip_file,tmp])
with ZipFile(zip_file, "r") as z:
z.extractall(tmp)
print('Unzip finished')
addon_dir_src = join(tmp,zip_dir,addon_dir)
addon_dir_dst = join(path_to_addons,addon_dir)
print('remove previous addon')
rmtree(addon_dir_dst,True)
print('add latest addon')
copytree(addon_dir_src,addon_dir_dst)
print('enable addon')
addon_utils.enable("robot_designer_plugin", persistent=True)
bpy.ops.wm.save_userpref()
with open(join(addon_dir_src,"requirements.txt")) as f:
for line in f:
rc = call([python_exec,"-m","pip","install",line])
#pip.main(['install', line])
print('RD Installation Done!')
Und this is the error raised in the terminal:
Install Pip
Download RD
OpenSSL 0.9.8zh 14 Jan 2016
Unzip RD
/var/folders/nm/9nfcg98x4hxf1kh08dj8p92h0000gn/T/tmpvd4k0lfi/master.zip
Traceback (most recent call last):
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1107, in request
self._send_request(method, url, body, headers)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1152, in _send_request
self.endheaders(body)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1103, in endheaders
self._send_output(message_body)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1261, in connect
server_hostname=server_hostname)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 385, in wrap_socket
_context=self)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 760, in __init__
self.do_handshake()
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 996, in do_handshake
self._sslobj.do_handshake()
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 641, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/gaoyingqiang/Downloads/installer.blend/Text", line 40, in <module>
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 188, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 466, in open
response = self._open(req, data)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 484, in _open
'_open', req)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1297, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1256, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)>
Error: Python script fail, look in the console for now...
I really don't know where goes wrong since the plugin provides no further imformation on this issue. How can I fix this?
New edition:
I now want to solve the issue of how to upgrade the openssl version in the python which is in the Blender. Blender brings python3.5 with it and how can I brew install openssl to this python but not the python on my disk?

python pip install failures

i am trying to install a library pynput using
sudo pip install pynput
but i am getting this error log. This has been happening with any other python package. everything used to work fine suddenly these errors are appearing i tried to copy error log from
~/.pip/pip.log
and this is what i have:
Using version 1.4 (newest of versions: 1.4, 1.3.10, 1.3.9, 1.3.8.1, 1.3.7, 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3, 1.2, 1.1.7, 1.1.6, 1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1, 1.0.6, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0, 0.6, 0.5.1, 0.5, 0.4, 0.3, 0.2)
Cleaning up...
Removing temporary dir /tmp/pip_build_root...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 546, in unpack_http_url
resp = session.get(target_url, stream=True)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 467, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 558, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/adapters.py", line 330, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 562, in urlopen
body=body, headers=headers)
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 1017, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1051, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 1013, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 864, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 826, in send
self.connect()
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 145, in connect
match_hostname(self.sock.getpeercert(),
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 313, in getpeercert
for value in get_subj_alt_name(x509)
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 94, in get_subj_alt_name
asn1Spec=general_names)
File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 825, in __call__
stGetValueDecoder, self, substrateFun
File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 391, in valueDecoder
r.verifySizeSpec()
File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/base.py", line 252, in verifySizeSpec
def verifySizeSpec(self): self._sizeSpec(self)
File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/constraint.py", line 32, in __call__
'%s failed at: \"%s\"' % (self, sys.exc_info()[1])
ValueConstraintError: ConstraintsIntersection(ConstraintsIntersection(), ValueSizeConstraint(1, 64)) failed at: "ValueSizeConstraint(1, 64) failed at: "SubjectAltName().setComponents(GeneralName(componentType=NamedTypes(NamedType('otherName', AnotherName(componentType=NamedTypes(NamedType('type-id', ObjectIdentifier('<no value>')), NamedType('value', ...........
A similar issue exists here.
The problem seems to be that the PyPI certificate now has more than 64 SAN names on it, breaking the hardcoded maximum in older versions of requests.
Make sure you have recent versions of both the requests and urllib3 modules.
You need to update pip. Just enter this command
curl https://bootstrap.pypa.io/get-pip.py | sudo python
After update bash -l
That's it.
I got it working by.
removing requests, urllib manually from
/usr/local/lib/python2.7/dist-packages
and reinstalling requests with sudo easy_install requests
then sudo easy_install pip==9.0.1
Try updating pip using
sudo -H pip2 install --upgrade pip
command.
Below solution worked for me.
Uninstall pip2
Install pip2 using PyPI (Refer 'Install pip From PyPI' section in https://www.howtodojo.com/2016/03/install-use-pip-ubuntu-14-04/)
Note: Install from ubuntu repository didn't work in my case.
Then I no longer got ValueConstraintError while installing any module using pip2 (ex: pip2 install invoke)

Python Request module, getting SSLError even with verify=False

When I tried to get the web page with Python Requests module for the first time on Elementary OS, I faced with SSLError. There is simple solution:
Python 3, trying:
import requests
page = requests.get('https://api.github.com/events')
Getting SSLError:
/usr/local/bin/python3 /home/led/PycharmProjects/urllib_p/urllib_p.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 549, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 251, in _get_conn
return conn or self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 764, in _new_conn
raise SSLError("Can't connect to HTTPS URL because the SSL "
requests.packages.urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/led/PycharmProjects/urllib_p/urllib_p.py", line 5, in <module>
page = requests.get('https://api.github.com/events')
File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
verify=False make no sense (same Error)
Go to Python_directory/Modules (Python-3.6.4/Modules in my case).
Open Setup file with text editor and search for SSL. You will find this:
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto
Uncomment last four lines.
In terminal: go to Python_directory, then:
sudo ./configure
sudo make
sudo make install
I fixed this with those commands:
sudo cp -f /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/local/lib/
sudo cp -f /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/local/lib/
sudo ln -sfn /usr/lib/x86_64-linux-gnu/libcrypto.a /usr/local/lib/
sudo ln -sfn /usr/lib/x86_64-linux-gnu/libssl.a /usr/local/lib/
sudo ln -sfn /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/local/lib/

How to completely remove and install again PIP on MacOS Sierra (10.x)?

Had PIP working normally until few days ago.
Not sure how.
Trying to run it now and now show issues.
Adding full stack bellow of the error:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 487, in _prepare_file
req_to_install, finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 428, in _check_skip_installed
req_to_install, upgrade_allowed)
File "/usr/local/lib/python2.7/site-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/local/lib/python2.7/site-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/local/lib/python2.7/site-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/local/lib/python2.7/site-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/local/lib/python2.7/site-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 390, in send
conn = self.get_connection(request.url, proxies)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 290, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 194, in proxy_manager_for
**proxy_kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/poolmanager.py", line 367, in proxy_from_url
return ProxyManager(proxy_url=url, **kw)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/poolmanager.py", line 312, in __init__
proxy = parse_url(proxy_url)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/url.py", line 189, in parse_url
raise LocationParseError(url)
LocationParseError: Failed to parse: user:pass
Want to try to reinstall pip completely.
What is recommended way to do it?
Your pip and Python installations are fine. What's wrong is your proxy configuration.
On OS X, both environment variables and the OS X network configuration can supply proxy information. First find out what configuration you have with:
python2.7 -c 'import urllib, pprint; pprint.pprint(urllib.getproxies())'
then look for any incorrect configuration in both your network settings (in the system configuration, check active networks for the proxies tab), and in your environment variables for *_proxy entries (http_proxy, https_proxy, etc.).
You can manually override proxies by setting one on the command line with the --proxy switch:
pip --proxy= install ...
Note the empty --proxy=; or you can set a specific proxy.
If you really did need to re-install your Python setup, you appear to have installed yours with Homebrew, so you can re-install it with brew install -f python#2.
Download Anaconda (or Miniconda), run it, and restart your terminal then start using environments.
to create an environment type
conda create -n my_project_name python=3.6
conda activate my_project_name
Now do all the pip installs and conda installs you want.
Your path is fixed. Pip is fixed. Go crazy.
Edit:
Now that you've posted your full traceback it looks like you need to feed the proxy a username and password. Here is one way to do it.
pip install --proxy=https://user#mydomain:port somepackage

Categories

Resources