HTTP Error 402 when installing virtualenvwrapper-powershell - python

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.

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.

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

Related

Installing Jupyter Notebook using pip in Ubuntu 14.04

I am trying to install jupyter notebook but for some reasons I am not able to install it. I have looked into several links like this and this but it did not help me. I am guessing the problem here is with the installation of pip. When I check the version of pip I get the following result :
shaloin#shaolin-Inspiron-3543:~$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
But when I try to upgrade the version of pip, I am getting this error :
shaloin#shaolin-Inspiron-3543:~$ sudo pip install --upgrade pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip in /usr/lib/python2.7/dist-packages
Downloading/unpacking pip
Cleaning up...
No distributions at all found for pip in /usr/lib/python2.7/dist-packages
Storing debug log for failure in /home/shaloin/.pip/pip.log
So, I searched for the error and I got to know that if you are behind proxy you should try out the following command :
sudo pip --proxy [NITS:abcde#]172.16.30.20:8080 install jupyter
where NITS is the usename abcde is the password , proxy server = 172.16.30.20 and password=8080, after which I got the following error :
Downloading/unpacking jupyter
Cleaning up...
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 1178, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_page
session=self.session,
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 670, in get_page
resp = session.get(url, headers={"Accept": "text/html"})
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 305, in send
conn = self.get_connection(request.url, proxies)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/adapters.py", line 206, in get_connection
except_on_missing_scheme(proxy)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/utils.py", line 636, in except_on_missing_scheme
raise MissingSchema('Proxy URLs must have explicit schemes.')
MissingSchema: Proxy URLs must have explicit schemes.
Storing debug log for failure in /home/shaloin/.pip/pip.log
I also tried setting up my proxy in this way :
set http_proxy=http://username:password#proxyAddress:port
set https_proxy=https://username:password#proxyAddress:port
but none of that works for installing jupyter notebook using pip.
Please don't mark this question as duplicate as because I have been searching for the solution for a long time and none of them works.
Can anyone please help??
For Ubuntu 14.04
I solved the problem of installation using anaconda. The description is given in this link.I couldn't fix the problem of upgrading pip. The steps for installing jupyter notebook is given below :
Step 1 (refer here)
First we install anaconda using wget
32 bits version
wget
https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda-2.3.0-Linux-x86.sh
64 bits version
wget
https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda-2.3.0-Linux-x86_64.sh
Step 2
After the download is over :
32 bits version
bash Anaconda-2.3.0-Linux-x86.sh
64 bits version
bash Anaconda-2.3.0-Linux-x86_64.sh
After downloading anaconda, open your terminal and type the following command :
$ sudo gedit ~/.profile
Add the given line at th end of the file :
export PATH=~/anaconda2/bin:$PATH
Step 3
After adding the line save the file. Open a new terminal and go to the directory where anaconda was downloaded.
$ cd anaconda2/bin
~/anaconda2/bin$ source activate
(root):~/anaconda2/bin$ jupyter notebook
The jupyter notebook will be opened in the browser.
For more information on jupyter notebook you can refer to this link.

did you run python setup.py develop?

Hy Everyone,
I try to install a script on my server using a terminal but due the installation I get an error. I will past here, the last lines of terminal.
Traceback (most recent call last):
File "/usr/bin/paster", line 4, in
command.run()
File "/usr/lib/python2.7/dist-packages/paste/script/command.py", line 93, in run
commands = get_commands()
File "/usr/lib/python2.7/dist-packages/paste/script/command.py", line 135, in get_commands
plugins = pluginlib.resolve_plugins(plugins)
File "/usr/lib/python2.7/dist-packages/paste/script/pluginlib.py", line 82, in resolve_plugins
pkg_resources.require(plugin)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 725, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 628, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: httpagentparser==1.7.8: Not Found for: r2 (did you run python setup.py develop?)
oneprovider#dedi-fr-20388:~$
Can someone help me to fix it ? Should install python develop ? If yes, how ? :D
As the error message is quite clear: httpagentparser is not installed https://pypi.python.org/pypi/httpagentparser
You should install it first, maybe it's available in the ubuntu software center. Else install via pip:
pip install httpagentparser
And if you don't know pip and/or have pip not installed. See https://pip.pypa.io/en/stable/installing/

python: How to create virtualenv without internet connection

I have trouble creating a virtualenv on a server that blocks all internet access. Has anybody successfully done that before? I searched but doesn't show up anything helpful. I have no problem transferring data back and forth, but I don't know what packages need to be downloaded and what options I need to have for the installation.
If you are curious what I got by trying to create one, here's the backtrace:
netops#netops1 /spare/local/latency $virtualenv -p /usr/bin/python2.6 latency
Running virtualenv with interpreter /usr/bin/python2.6
New python executable in latency/bin/python2.6
Also creating executable in latency/bin/python
Installing setuptools.....................
Complete output from command /spare/local/latency/latency/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" --always-copy -U setuptools:
Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
Traceback (most recent call last):
File "<string>", line 279, in <module>
File "<string>", line 211, in main
File "<string>", line 159, in download_setuptools
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 1181, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib64/python2.6/urllib2.py", line 1156, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>
Thanks for any help.
If you update virtualenv to a version >= 1.10, then it will never connect to the internet regardless of any flag (see the "Changes & News" section here)
The internet connection is used to install the setuptools and pip packages in the virtual environment. Older versions of virtualenv will try to download these two packages, while newer versions ship with them and will just unpack them when necessary.
Since your virtualenv version (1.7.2) is lower than 1.10, you can use the --never-download flag in order to avoid connecting to the internet. Later on, you can install (offline) what you need.
Here (section "The --extra-search-dir Option") it's explained how to bootstrap setuptools and pip without an internet connection. You basically need to get the .egg files for these packages and put them somewhere local, and then you need to do:
$ virtualenv --extra-search-dir=/path/to/eggs --never-download ENV
mkdir .mypypi
pip install --download $HOME/.mypypi ipython ipdb django
Now transfer the contents from .mypypi to your server. Let's say you copied it to your $HOME Then do this:
pip install --no-index --find-links=file:/$HOME/.mypypi ipython
This should work for requirements.txt file too.

pyjamas - pyjsbuild error due to DistributionNotFound

I am trying to build the HelloWorld example page from the Pyjamas example folder. However I am receiving this error when I run: sudo pyjsbuild helloworld.py. This error seems pretty universal to python as it seems to be related to the setup/configuration of my python environment. Any advice on where to look for the problem?
Here is the error
Traceback (most recent call last):
File "/usr/local/bin/pyjsbuild", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: six
After trying the various answers, it turns out pip was not properly installing the six package, whatever that is. So I ran sudo easy_install pip (--upgrade) to make sure the script configuration was right. It wrote some extra files so I assume that's why my next command sudo pip install six or sudo pip install six --upgrade worked. Now I ran into another error -_-, For anyone looking later: Runtime Error: Top module not found 'hello world'
Edit: The top module error is coming from trying to build into the output folder that is not pyjs/. All I had to do was move the folder up to pyjs/ folder in sitepackages/.

Python with MySQL on Windows: installation errors

I tried to run the following command, in the folder of my Django project:
$ python manage.py dbshell
It shows me this error:
$python manage.py dbshell
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
362, in execute_manager
utility.execute()
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 195,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 222,
in execute
output = self.handle(*args, **options)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 351,
in handle
return self.handle_noargs(**options)
File "C:\Python25\lib\site-packages\django\core\management\commands\dbshell.py
", line 9, in handle_noargs
from django.db import connection
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 41, in <modul
e>
backend = load_backend(settings.DATABASE_ENGINE)
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 17, in load_b
ackend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py", line 13
, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb
First question is, why does Python not simply include this MySQLdb module?
OK, just fine, try to search to solve this message.
I have looked around stackoverflow.com for installing this module but did not have a good result.
Download this module at: http://sourceforge.net/projects/mysql-python/
Comes to the installation of this module on my Windows Vista system.
After the extraction of the package, I run the cmd prompt to continue with the installation:
$ python setup.py install
Again it showed me one other message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
Playing around with this error message, I know that there is the ez_setup.py within the package:
$python ez_setup.py
It seems that everything is OK:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python ez_setup.py
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py
2.5.egg
Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to c:\python25\lib\site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install-script.py script to C:\Python25\Scripts
Installing easy_install.exe script to C:\Python25\Scripts
Installing easy_install-2.5-script.py script to C:\Python25\Scripts
Installing easy_install-2.5.exe script to C:\Python25\Scripts
Installed c:\python25\lib\site-packages\setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9
Now comes back to the setup.py to install again:
$python setup.py install
It again gave me one other error message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
running install
running bdist_egg
....
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.5\MySQLdb\constants
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
How can I fix this problem?
Did you try looking here: http://sourceforge.net/projects/mysql-python/files/
That is the download area of MySQLdb project, it has nothing to do with django, so your question is incorrect - django does not make switching database backends hard, you just change one line. And of course, your python installation should support that database first, so by downloading binary package for Windows from the link I gave above (chose correct version to match your version of python) you can avoid all the hassle of compiling the source release.
Most probably you need either MySQL-python-1.2.2.win32-py2.5.exe or MySQL-python-1.2.2.win32-py2.4.exe
Uh, this isn't Django, this is you downloading some unspecified Python environment and expecting it to magically do everything exactly the way you wanted it to. Find a good tutorial on this and follow the instructions.
BTW, this is a very helpful forum, but giving no specifics and then delivering a non-question with an attitude is not a good way to get people to feel helpful.
I once had the same problem running Python and MySQL on the same computer. Like the guys/gals said above, Python does not come with built-in support for MySQL, so you will need to download the connectors.
The link given above by #kibitzer will most likely not work on Windows successfully, so go here to download a copy of the connector that works with windows. It comes with installer and no need to run setup.py script manually.

Categories