“ImportError: no module named 'requests'” after installing with pip

前端 未结 6 709
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 01:48

I am getting ImportError : no module named \'requests\'.

But I have installed the requests package using the command pip install req

相关标签:
6条回答
  • 2021-01-04 02:24

    I had this error before when I was executing a python3 script, after this:

    sudo pip3 install requests

    the problem solved, If you are using python3, give a shot.

    0 讨论(0)
  • 2021-01-04 02:27

    if it works when you do :

    python
    >>> import requests
    

    then it might be a mismatch between a previous version of python on your computer and the one you are trying to use

    in that case : check the location of your working python:

    which python And get sure it is matching the first line in your python code

    #!<path_from_which_python_command>
    
    0 讨论(0)
  • 2021-01-04 02:28

    One possible reason is that you have multiple python executables in your environment, for example 2.6.x, 2.7.x or virtaulenv. You might install the package into one of them and run your script with another.

    Type python in the prompt, and press the tab key to see what versions of Python in your environment.

    0 讨论(0)
  • 2021-01-04 02:30

    Run in command prompt.

    pip list
    

    Check what version you have installed on your system if you have an old version.

    Try to uninstall the package...

    pip uninstall requests
    

    Try after to install it:

    pip install requests
    

    You can also test if pip does not do the job.

    easy_install requests
    
    0 讨论(0)
  • 2021-01-04 02:34

    In Windows it worked for me only after trying the following: 1. Open cmd inside the folder where "requests" is unpacked. (CTRL+SHIFT+right mouse click, choose the appropriate popup menu item) 2. (Here is the path to your pip3.exe)\pip3.exe install requests Done

    0 讨论(0)
  • 2021-01-04 02:35

    Opening CMD in the location of the already installed request folder and running "pip install requests" worked for me. I am using two different versions of Python.

    I think this works because requests is now installed outside my virtual environment. Haven't checked but just thought I'd write this in, in case anyone else is going crazy searching on Google.

    0 讨论(0)
提交回复
热议问题