gladiator92
gladiator92

Reputation: 1

Import requests error in spite of requests installed

I have the following error: when I execute my code :

python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import requests
ImportError: No module named requests

Checks already done :

  1. pip list cmd result => seems OK

    pip (7.1.0)
    requests (2.7.0) => OK
    setuptools (12.0.5)
    wheel (0.24.0)
    
  2. Cmd results :

    pip install requests
    Requirement already satisfied (use --upgrade to upgrade): requests in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
    

=> seems OK.

  1. ls cmd confirms that the package in that folder.

    README              requests
    __pycache__         requests-2.7.0.dist-info
    _markerlib          setuptools
    easy_install.py         setuptools-12.0.5.dist-info
    pip             wheel
    pip-7.1.0.dist-info     wheel-0.24.0.dist-info
    pkg_resources
    

Thanks for you help.

Upvotes: 0

Views: 160

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83788

Please add output of python --version and import sys ; print(sys.path) in the question. You

  • most likely have multiple Python installations on your operating system

  • pip install installs the requests in one of the installations

  • ... but python command you try to run Python with modules from another installation

Please use virtualenv and Python package installation guide to create an isolated Python environment, so you know which modules are installed there and if there was any issue installing them.

Upvotes: 1

Related Questions