ImportError: No module named 'requests'

后端 未结 3 367
野的像风
野的像风 2021-01-22 03:24

Getting this error when trying to run a Python script. I have downloaded a requests-1.2.0 folder but I have no idea what to do with it. I\'ve tried running the setup.py file con

相关标签:
3条回答
  • 2021-01-22 03:50

    from the root directory of the requests folder you downloaded, run:

    $ python setup.py install
    

    then it will be installed system-wide, and your scripts may use "import requests"

    0 讨论(0)
  • 2021-01-22 04:01

    You need to install it for the same version of Python that you're using to run your script. The setup.py tells Python how to do that, so you can open up a command line to that directory (do you know how to do that?) and type python setup.py install to install it.

    But there's a much easier way -- Python has an excellent package manager, called pip. You can use that to install any other Python packages that you want by typing pip install requests at the command line. In particular, it will connect to the internet and work out what to download, then download and install it?

    0 讨论(0)
  • 2021-01-22 04:08

    You need to run setup.py with the "install" argument. That will install requests in the site-packages folder where it can be imported globally.

    Open a cmd window and navigate to the requests folder that you downloaded. Then type the following into the cmd window:

    C:\python27\python.exe setup.py install
    

    You'll need to change the path to the python executable to match that for your system, of course.

    PS: You're going to love requests!

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