Problem in installing "requests 2.1.0" in Python 3.3.3+Linux

A forum for general discussion of the Python programming language.

Problem in installing "requests 2.1.0" in Python 3.3.3+Linux

Postby arjun.mnemonic » Sun Dec 22, 2013 4:09 am

Hey people,

I was trying to install "requests 2.1.0" in Python 3.3.3, Linux Mint 16 x86_64. I downloaded the "requests-2.1.0.tar.gz" from their website.
When i try to run the command:
$ python3 setup.py install

it gives the following message:
Code: Select all
Traceback (most recent call last):
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
    from ssl import CertificateError, match_hostname
  File "/usr/local/lib/python3.3/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named '_ssl'

During handling of the above exception, another exception occurred:
Code: Select all
Traceback (most recent call last):
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 7, in <module>
    from backports.ssl_match_hostname import CertificateError, match_hostname
ImportError: No module named 'backports'

During handling of the above exception, another exception occurred:
Code: Select all
Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    import requests
  File "/home/arjun/Downloads/requests-2.1.0/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/home/arjun/Downloads/requests-2.1.0/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/home/arjun/Downloads/requests-2.1.0/requests/compat.py", line 7, in <module>
    from .packages import charade as chardet
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/connectionpool.py", line 31, in <module>
    from .packages.ssl_match_hostname import CertificateError
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
    from . import ssl_match_hostname
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 10, in <module>
    from _implementation import CertificateError, match_hostname
ImportError: No module named '_implementation'

I am at a complete loss here. Please suggest what to do.

Thanks a lot
Cheers!
Last edited by Yoriz on Sun Dec 22, 2013 1:13 pm, edited 1 time in total.
Reason: First post lock, Added code tags
arjun.mnemonic
 
Posts: 4
Joined: Sun Dec 22, 2013 3:55 am

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby metulburr » Sun Dec 22, 2013 12:19 pm

Does
Code: Select all
import _ssl

work on your python2.x installation? Or is it just your 3.x installation?

I would first try:
Code: Select all
sudo apt-get install openssl libssl-dev

and if you do not have either package, retry to install requests after that.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby arjun.mnemonic » Mon Dec 23, 2013 2:06 am

Hi,

I tried installing "requests 2.1.0" in Python 2.7.5 and it installed perfectly. But, when i try to install in Python 3.3.3, it gives the following error (when i run: python3 setup.py install
):
Code: Select all
Traceback (most recent call last):
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
    from ssl import CertificateError, match_hostname
  File "/usr/local/lib/python3.3/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named '_ssl'

During handling of the above exception, another exception occurred:
Code: Select all
Traceback (most recent call last):
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 7, in <module>
    from backports.ssl_match_hostname import CertificateError, match_hostname
ImportError: No module named 'backports'

During handling of the above exception, another exception occurred:
Code: Select all
Traceback (most recent call last):
  File "Downloads/requests-2.1.0/setup.py", line 6, in <module>
    import requests
  File "/home/arjun/Downloads/requests-2.1.0/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/home/arjun/Downloads/requests-2.1.0/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/home/arjun/Downloads/requests-2.1.0/requests/compat.py", line 7, in <module>
    from .packages import charade as chardet
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/connectionpool.py", line 31, in <module>
    from .packages.ssl_match_hostname import CertificateError
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
    from . import ssl_match_hostname
  File "/home/arjun/Downloads/requests-2.1.0/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 10, in <module>
    from _implementation import CertificateError, match_hostname
ImportError: No module named '_implementation'

I also tried your suggestion: apt-get install openssl libssl-dev
But it installed it to Python 2.7.5 and not 3.3.3
Also, pressing the up arrow key to repeat the last command is not working in Python 3.3.3 the way it works in 2.7.5

What is the next step?

Thanks a lot
Arjun
Last edited by Yoriz on Mon Dec 23, 2013 8:21 am, edited 1 time in total.
Reason: Added code tags
arjun.mnemonic
 
Posts: 4
Joined: Sun Dec 22, 2013 3:55 am

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby metulburr » Mon Dec 23, 2013 2:27 am

I also tried your suggestion: apt-get install openssl libssl-dev
But it installed it to Python 2.7.5 and not 3.3.3

that is not going to install it to either python version. It is going to install the libraries to your operating system. Did you do it? Did you isntall these libraries? Were these libraries already installed on your OS or what?

Also, pressing the up arrow key to repeat the last command is not working in Python 3.3.3 the way it works in 2.7.5

i am not sure what you are referring to?

Did you install python3.x via repo, or did you compile it yourself? I am not quite sure, but it might be a missing library, as i just installed the same requests version to my ubuntu servers python3.x, and had no problem. Plus you do not need to keep posting the traceback every time you respond.

Once you have these two packages, remove python3.x and reinstall it again. the retry to install requests after that.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby arjun.mnemonic » Mon Dec 23, 2013 7:02 am

Hey,

First of all, thanks a lot for your quick replies.

Yes, I installed the mentioned libraries. I think they weren't already present in my OS (Linux Mint 16).
As for the installation of Python 3.3.3, i downloaded "Python 3.3.3.tgz" from "python.org" download page. I compiled and installed it.

In Python 2.7.5, in order to repeat the last command(s), i just press the 'up' arrow key and the last command(s) gets executed. But, this functionality is absent in 3.3.3.
I run python interpreter while being in Terminal.

Thanks
arjun.mnemonic
 
Posts: 4
Joined: Sun Dec 22, 2013 3:55 am

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby metulburr » Mon Dec 23, 2013 11:43 am

i downloaded "Python 3.3.3.tgz" from "python.org" download page. I compiled and installed it.

Is there some reason that you compiled it yourself as opposed to installing it from ubuntu repos? The easiest solution is to install from the repos, which all debian distributions have access to, including mint. This way any dependencies get installed as well, and you avoid such problems in the first place. The only difference is the current python3.x in ubuntu repos is 3.2 as opposed to 3.3, which is not a big deal, unless your specifically using a feature in the latest python.
Code: Select all
sudo apt-cache search python3.2

Code: Select all
sudo apt-get install python3.2

but i would completely uninstall any and all of the python version you downloaded previously first
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby micseydel » Mon Dec 23, 2013 6:57 pm

metulburr wrote:
Code: Select all
sudo apt-get install python3.2

but i would completely uninstall any and all of the python version you downloaded previously first

IIRC correctly Ubuntu and Linux Mint use Python 2 internally. He probably doesn't want to uninstall the version that came with his system.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1115
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby metulburr » Tue Dec 24, 2013 12:01 am

IIRC correctly Ubuntu and Linux Mint use Python 2 internally. He probably doesn't want to uninstall the version that came with his system.

oh yeah, i meant python3.x version he installed.

@arjun.mnemonic
...Dont touch the 2.x version.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1300
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby arjun.mnemonic » Tue Dec 24, 2013 12:56 am

i tried the command to install "python 3.2" ('apt-get install python3.2' after running 'apt-cache search python3.2') but it gives the output:

E: Unable to locate package python3.2
E: Couldn't find any package by regex 'python3.2'

(I know this problem belongs to linux mint forum. Just thought of letting you know)
arjun.mnemonic
 
Posts: 4
Joined: Sun Dec 22, 2013 3:55 am

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby casevh » Tue Dec 24, 2013 4:12 am

Some background on installing software on Unix/Linux systems...

Compiling the source code for library (or application) produces two sets of files: the compiled-to-binary files (library and/or application) and the information files needed by other applications so they can use the library. Most Linux distributions split the files into two packages. The binary files are always downloaded but the development files are rarely downloaded by default. If you always install packages from the distribution's repository, you don't need the development files. You need the development files when you compile software yourself.

You mentioned that the cursor keys don't work in the Python 3.3 that you compiled. The cursor keys and history are implemented by a fairly standard library called "readline". The binary files are provided by a package called "libreadline". The development files are provided by package called "libreadline-dev". Different distributions may use slightly different naming conventions but the idea is the same.

You will need to install the development packages for libreadline and openssl (or libssl or libopenssl or ???). If you want to compile every library in Python, you'll also need to install several other libraries (and unfortunately I don't list handy). After you run "make", the build script will usually state that it couldn't find the correct bits to support some library. If those libraries are important to you, then you'll need to install the missing development files.

I normally leave the distribution's version(s) of Python alone and do all my development on my own installations of Python. I create symlinks to the new versions with different names. For example, python and python3 are the distribution's versions, and mine are called py26, py27, py32, py33, and py34.

Let me know if you need more details/suggestions.

casevh
casevh
 
Posts: 67
Joined: Sat Feb 09, 2013 7:35 am

Re: Problem in installing "requests 2.1.0" in Python 3.3.3+L

Postby dboxall123 » Tue Dec 24, 2013 12:09 pm

Forget trying to install python3.2. Just do this:
Code: Select all
sudo apt-get install python3

There's no need to specify the .2 bit.
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests