2

Python version: 2.7.13

OS: Windows Server 2012

Following this tutorial to set up Python environment

When I attempt to execute

pip install virtualenvwrapper-powershell

I get error

Collecting virtualenvwrapper-powershell
  Using cached virtualenvwrapper-powershell-12.7.8.zip
    Complete output from command python setup.py egg_info:
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\sahluw~1\appdata\local\temp\pip-build-2szqsq\virtualenvwrapper-powershell\setup.py", line 11, in <m
odule>
        distribute_setup.use_setuptools()
      File "distribute_setup.py", line 145, in use_setuptools
        return _do_download(version, download_base, to_dir, download_delay)
      File "distribute_setup.py", line 124, in _do_download
        to_dir, download_delay)
      File "distribute_setup.py", line 193, in download_setuptools
        src = urlopen(url)
      File "c:\python27\lib\urllib2.py", line 154, in urlopen
        return opener.open(url, data, timeout)
      File "c:\python27\lib\urllib2.py", line 435, in open
        response = meth(req, response)
      File "c:\python27\lib\urllib2.py", line 548, in http_response
        'http', request, response, code, msg, hdrs)
      File "c:\python27\lib\urllib2.py", line 473, in error
        return self._call_chain(*args)
      File "c:\python27\lib\urllib2.py", line 407, in _call_chain
        result = func(*args)
      File "c:\python27\lib\urllib2.py", line 556, 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 c:\users\xxx~1\appdata\local\temp\pip-build-2szqsq\vir
tualenvwrapper-powershell\

How to successfully enable SSL? Tried enabling SSL and TLS based on this link and restarting the Server, but no luck

Or at least, any work-around.

Rhonda
  • 1,661
  • 5
  • 31
  • 65

2 Answers2

1

I'm not a developer and I reckon I'm not entirely qualified to explain exactly how this should be solved, but I've recently had the same issue and just spent most part of 2 days scouring the internet for a solution.

I have python3.6 and python2.7 installed so for me there is a slight juggling of order of environment variables needed. Easiest seems to be to keep the python2.7 env vars on top for installing

pip install virtualenv

and then the way I solved the SSL 403 Error was to witch the environment variables around again, putting python3 on above python2, so that pip installs with python3 and then download the actual virtualenvwrapper-powershell package [virtualenvwrapper-powershell-12.7.8.zip] from here: https://pypi.python.org/pypi/virtualenvwrapper-powershell

Once you got that there are a few links I got information from: https://bitbucket.org/guillermooo/virtualenvwrapper-powershell/issues/5/cant-install-package-with-python3-and-pip

and

https://bitbucket.org/guillermooo/virtualenvwrapper-powershell/issues/21/build-error-with-old-distribute

So using these two links, we're now installing envwrapper with python3 and getting another error: TOKEN_READ. That's (was for me) solved by editing the distribute_python.py file in the zip you downloaded above by changing Line 50 assignment, by putting an 's' after the 'DEFAULT_URL = http'. Keep the rest of the URL in the quotes there, just make it an SSL address. Next open the setup.py file in the same ZIP, and edit Line 76 by removing teh 'L' following the number following the TOKEN_READ variable.

This should take care of both the TOKEN_READ error which seems to have something to do with python3 and virtualenvwrapper, as well as the SSL error that we both seem to have experienced, which seem to have something to do with the version of the distribute file.

Once this is done you should be able to

pip install virtualenvwrapper-powershell

Restart powershell, and

Import-Module virtualenvwrapper

if you now get two other errors, the first one should be a Function:/TabExtension Error

That's solved by finding and editing the file that you see in the path in the error message and just adding a '2' after Function/TabExtension on Line 12 i think. Save and restart powershell. The other error if you have one is taken care of by creating your system environment variable for WORKON_HOME. Instructions here: http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/ and here: https://rseshan.wordpress.com/2017/04/05/configuring-virtualenv-for-python-on-windows-10-using-powershell-wrapper/

As well as all this I also installed ez_setup.py from the tutorial linked to in your question. As well as after that force re-installing PIP by:

python -m pip install --upgrade --force-reinstall pip

But I have absolutely no clue if this is at all needed as it didn't help on its own, before I did the manual wrapper modifications described above.

Hope this helps! But this got it working for me, after hours of googling my heart out ;)

ADDON in regards to the comment below:

Of course the downloaded envwrapper ZIP file needs to be installed at the path where it sits on the drive after download, so rather than just doing pip install virtualenvwrapper-powershell it was in my case pip install C:\Users\*USER*\Downloads\virtualenvwrapper-powershell-12.7.8\virtualenvwrapper-powershell-12.7.8

Now another error that occurred, covered here

..is that virtualenvwrapper might install itself in a strange location which causes an Error when you try to use Import-Module virtualenvwrapper In my case that was: C:\Program Files (x86)\Python27\Lib\site-packages\Users*USER*\Documents\WindowsPowerShell\Modules\VirtualEnvWrapper instead of C:\Users*USER*\Documents\WindowsPowerShell\Modules\VirtualEnvWrapper I simply cut/pasted the Modules folder with everyting in it to the correct folder in the User/Documents folder where it can be found by the Powershell profile. I just thought I'd add this as I just went through all these steps again today.

dflamholc
  • 52
  • 8
  • Oh my! Very thorough and detailed! I will try this out and keep you updated. – Rhonda Nov 09 '17 at 13:19
  • I just tried these instructions today myself on a completely fresh win10 system. I did get another issue which was covered here on stackoverflow before in regards to where the manual .zip virtualenvwrapper installation might choose to land. I've edited the answer above to reflect this. – dflamholc Nov 11 '17 at 13:54
  • Thank you so much for this detailed and helpful post. When I get a chance will go through this. – Rhonda Nov 11 '17 at 19:17
  • What. The. Hell. I'm going back to Mac. – Alex Whittemore Dec 29 '17 at 17:06
0

Download the zip file:

https://files.pythonhosted.org/packages/f5/40/36d418b950139cd09738c0924066ef340ffd6c43f79f67c6152c56a8a628/virtualenvwrapper-powershell-12.7.8.zip

Unzip the file, open distribute_setup.py, and change DEFAULT_URL from http to https, rezip the file (to a fresh zip file).

pip install path_to_zipfile
4b0
  • 21,981
  • 30
  • 95
  • 142
  • Use more generic links than a specific version as it can be absolute in future. https://pypi.org/project/virtualenvwrapper-powershell/ – vmorusu Jun 17 '19 at 19:04