0

I am new to PyDev and Python and trying to run a python program on LiClipse ( version: 2.5.4....) on Windows 7 and seeing this error. This program is importing requests.

I am using python 2.7

Did some research on this error and according to the information:

For Windows without PowerShell 3 or for installation without a command-line, download ez_setup.py using your preferred web browser or other technique and “run” that file.

from : https://pypi.python.org/pypi/setuptools

I ran and installed as :

c:\opts\Python27>python.exe ez_setup.py

Looks like it's been installed as last few lines are :

removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing setuptools-21.0.0-py2.7.egg
Copying setuptools-21.0.0-py2.7.egg to c:\opts\python27\lib\site-packages
Adding setuptools 21.0.0 to easy-install.pth file
Installing easy_install-script.py script to c:\opts\Python27\Scripts
Installing easy_install.exe script to c:\opts\Python27\Scripts
Installing easy_install-2.7-script.py script to c:\opts\Python27\Scripts
Installing easy_install-2.7.exe script to c:\opts\Python27\Scripts

Installed c:\opts\python27\lib\site-packages\setuptools-21.0.0-py2.7.egg
Processing dependencies for setuptools==21.0.0
Finished processing dependencies for setuptools==21.0.0

Restarted Liclipse but the problem did not go away. Any help?

Part of the code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, requests, json, argparse, unittest, hmac, base64, urllib, urlparse, hashlib

class ClassificationCategory:

........

def post(self, endpoint, payload = None, params = None, headers = None, files = None):
    if payload is not None:
        data = payload if isinstance(payload, basestring) else json.dumps(payload)
    else:
        data = None
    self.res = requests.Session().send(self.prepare_request(endpoint, method = 'POST', params = params, data = data, files = files, headers = self.prepare_headers(headers)), verify = False)
    return self

instance=ClassificationCategory()
instance.post(......)
5
  • Which program is importing request? Commented May 5, 2016 at 21:08
  • my own python program Commented May 5, 2016 at 21:41
  • What is requests? Can you show the code? I'm not sure if this is the issue, however in your title it shows: requests where in your description you say request Commented May 5, 2016 at 21:46
  • Updated with part of the code. Commented May 5, 2016 at 22:00
  • do a pip install requests from the command line. I don't think that your have requests installed. Commented May 5, 2016 at 22:26

1 Answer 1

2

Thanks Busfault. Your response was helpful.

'requests' does not come as default with Python. Need to install separately. One way to install is how busfault suggested above. But for some reasons this was not working for me. I had this error:

 C:\opts\Python27>pip install requests
 Collecting requests
 Could not find a version that satisfies the requirement requests (from versions: )
 No matching distribution found for requests

Hence I resolved it this way:

Download from : https://pypi.python.org/pypi/requests/2.7.0#downloads

Then Unzip and install as : python setup.py install (Make sure Python is in your path)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.