top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Proxy connection with Python

0 votes

I have an issue that has been frustrating me for a while now.

This is an update of a crosspost
which I made over a month ago.

I have been attempting to connect to URLs from python. I have tried: urllib2, urlib3, and requests. It is the same issue that i run up against in all cases. Once I get the answer I imagine all three of them would work fine.

The issue is connecting via proxy. I have entered our proxy information but am not getting any joy. I am getting 407 codes and error messages like: HTTP Error 407: Proxy Authentication Required (Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

I think that this also stops me using pip to install (at least from remotes ). I get 'Cannot fetch index base URL". I end up using git to clone a local copy of the repo and install from that.

However, I can connect using a number of other applications that go through the proxy, git and pycharm for example. When I run git config -- get htpp.proxy it returns the same values and format that I am entering in Python namely:


An example of code in requests is

import requests
proxy = {"http": "http://username:password@proxy:8080"}
url = ''
r = requests.get(url, proxies=proxy)
print r.status_code
posted Jun 26, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
0 votes

For testing purposes I want my code to raise a socket "connection reset by peer" error, so that I can test how I handle it, but I am not sure how to raise the error.

+1 vote

I'm trying to multiply two matrices that has different size.

import numpy as np

a = np.random.randn(4, 3)
b = np.random.randn(4, 1)

print a
print b

How should I multiply a and b so that the multipled matrix's size is 4*3?

I want to multiply matrix 'b' to each row of matrix 'a'.
So that if matrix a is
[[1, 2, 3],
[2, 3, 4]]
and b is
a*b is
[[2, 4, 6],
[4, 6 ,8]]

Plz help me, if possible, plz use numpy

+1 vote

A list can contain different types of elements but I am not able to understand how max () method work with different types of data elements.

0 votes

I can create a list that has repeated elements of another list as follows:

xx = ["a","b"]
nrep = 3
print xx
yy = []
for aa in xx:
 for i in range(nrep):
print yy


['a', 'b']
['a', 'a', 'a', 'b', 'b', 'b']

Is there a one-liner to create a list with repeated elements?

Useful Links with Similar Problem
Contact Us
+91 9880187415
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.