Getting error 403 while installing package with pip
Asked Answered
V

5

20

getting an error while installing google app engine using pip

Collecting google_appengine
  Downloading google-appengine-1.5.1.tar.gz (897kB)
    100% |████████████████████████████████| 901kB 1.9MB/s 
    Complete output from command python setup.py egg_info:
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/88/5jq5gz011sl63h_37k_qftv40000gn/T/pip-build-vxx8Ov/google-appengine/setup.py", line 3, in <module>
        ez_setup.use_setuptools()
      File "/Users/user/path to project/project/venv/lib/python2.7/site-packages/ez_setup.py", line 145, in use_setuptools
        return _do_download(version, download_base, to_dir, download_delay)
      File "/Users/user/path to project/project/venv/lib/python2.7/site-packages/ez_setup.py", line 124, in _do_download
        to_dir, download_delay)
      File "/Users/user/path to project/project/venv/lib/python2.7/site-packages/ez_setup.py", line 193, in download_setuptools
        src = urlopen(url)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
        return opener.open(url, data, timeout)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
        response = meth(req, response)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
        'http', request, response, code, msg, hdrs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
        return self._call_chain(*args)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
        result = func(*args)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
        raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 403: SSL is required

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/88/5jq5gz011sl63h_37k_qftv40000gn/T/pip-build-vxx8Ov/google-appengine/`
Vernonvernor answered 27/10, 2017 at 4:24 Comment(10)
can you try it with --trusted-host parameter pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org google-appengine Cutlip
No Its not workingVernonvernor
can you provide OS details ? and try updated commandCutlip
I am using OSX and tried above command got this error Could not find a version that satisfies the requirement google-appengine (from versions: ) No matching distribution found for google-appengineVernonvernor
It looks like issue with pip itself github.com/pyca/cryptography/issues/2692 try upgrading pip if it works pip install --upgrade pip or you can try with easy_install2.7 google-appengineCutlip
Pip is the latest versionVernonvernor
even with easy_install google-appengine isn't working?Cutlip
Let us continue this discussion in chat.Vernonvernor
below solution is not working for me! Any other solution, I'm facing the same issue while installing google-appenginePuling
which package are you trying to install ?Vernonvernor
K
25

It's because PyPI has disabled non HTTPS access to APIs

https://mail.python.org/pipermail/distutils-sig/2017-October/031712.html

as workaround you can use

$ pip install xxxx -i https://pypi.python.org/simple/
Kemme answered 27/10, 2017 at 16:21 Comment(5)
Now thousands github python repos all over the place will start getting 403 SSL issues from users. A round of applause to distutils team.Raze
If you know the URL of the project you can install directly from there. For example, pip install git+https://github.com/<user>/<project>.Delwyn
@MaxShenfield, thanks, being able to use git with pip is SOOO useful!Arthro
this did not work unless we upgraded the libssl on our 12.04 ubuntu!Dispread
Does not work for meDomicile
D
3

Unfortunately none of the previous answers work for me.

IMHO it was very stupid pip / distutils chose to break packages on http repos.

I think a better choice would have been:

  • pip/distutils use https by default

  • in case of error, like 403, pip has to suggest you "the package repo is on http, do you want to download it?"

Still in 2020 many Python 2 packages are on http repos; with their decision, the installation of these packages is broken.


The working solution for me is a very simple patch of one python core modules:

--- /usr/local/lib/python2.7/urllib2.py.original
+++ /usr/local/lib/python2.7/urllib2.py
@@ -427,6 +427,9 @@
             req = meth(req)

         response = self._open(req, data)
+        if protocol == "http" and response.code == 403 :
+            if isinstance(fullurl, basestring) and fullurl.startswith("http://pypi.python.org/packages/source/d/distribute/") :
+                return    self.open(fullurl.replace("http://", "https://"), data = data, timeout = timeout)

         # post-process response
         meth_name = protocol+"_response"

Working: if the failed url is on http, retry on https.

I know it is a little ugly, but it is very clear and also you can revert to the original module in a snap (make a copy of /usr/local/lib/python2.7/urllib2.py before to apply this patch).

Dermatologist answered 20/5, 2020 at 21:16 Comment(2)
Thanks a lot! This fix of yours is really MUCH more useful (and elegant) than the accepted answer, especially because that one doesn't seem to work anymore either.Higdon
Where is this on windows?Erasure
D
0

The only solution that worked for me was using easy_install instead of pip

Domicile answered 8/12, 2022 at 19:9 Comment(0)
P
0

If the Python project has a Git URL then you can try this command which will do pip install with git.

python -m pip install git+https://github.com/<user>/<project>

However, if the project has any dependencies and the dependencies also suffer from same problem (the usual case), then such dependencies will also fail.

Pinebrook answered 4/12, 2023 at 20:4 Comment(0)
V
-1

Got the error. The problem was with the repo from where pip was trying to install the package.

Vernonvernor answered 3/11, 2017 at 5:22 Comment(1)
How did you fix this problem?Doff

© 2022 - 2024 — McMap. All rights reserved.