No module named requests python windows

Решение проблемы с ошибкой ImportError: No module named requests

Если при запуске программы на Python у вас появляется сообщение об ошибке:

значит у вас отсутствует модуль Requests. Requests не является встроенным модулем, поэтому его нужно загрузить. Официальная документация по модулю: https://pypi.python.org/pypi/requests

OSX/Linux

Если у вас установлен pip, для установки в OSX/Linux используйте команду:

Обратите внимание на версию, чтобы явно указать, для какой версии Python вы делаете установку, используйте pip2 или pip3.

На OSX если у вас установлен easy_install, вы также можете использовать

Windows

В этой операционной системе используйте команду:

Если у вас машина на Windows, где если он был установлен, easy_install может быть найден в вашем каталоге Python*\Scripts. (Помните, Path\easy_install.exe — это пример, моя, к примеру, такая C:\Python32\Scripts\easy_install.exe)

Если у вас Windows машина без установленного easy install, то вы можете получить его здесь: http://www.lfd.uci.edu/

Если вы хотите добавить библиотеку на Windows машине вручную, вы можете загрузить сжатую библиотеку, разархивировать и затем поместить в каталог Lib вашего Python.

Из исходников (универсальный способ)

Любая отсутствующая библиотека, обычно, доступна в исходниках на: https://pypi.python.org/pypi/. Затем:

На mac osx и Windows, после загрузки zip с исходником, распакуйте его и из терминала/cmd запустите

ImportError: No module named ‘requests’ Python 3.4.0

When attempting to import the requests module in Python 3.4.0 I receive the following error: ImportError: No module named ‘requests’

The requests module in previous version of Python required that you use pip separately. But according to the new features in Python 3.4.0, pip is built in: https://docs.python.org/3.5/whatsnew/3.4.html#whatsnew-pep-453

My import line is simply:

I am confused as to why this is not working. All help is greatly appreciated.

Читайте также:  Версия windows через консоль

3 Answers 3

Having pip included is meant to ease retrieving new packages. It does not state that all modules reachable through pip are bundled in new Python (hopefully !).

You are still required to pip install requests before using the package requests .

Edit: following another question, it seems dependencies on requests are flawed. Then try:

as suggested by mentioned SO question.

There is a possible answer here.

  1. Install pip for python 3: sudo apt-get install python3-pip
  2. Use pip3 to install request module: pip3 install requests

If you get permission denied error, run the previous command in sudoers mode: sudo pip3 install requests

Although pip is built-in, you still have to call pip install requests . pip is just the tool for downloading, not the actual item. To download, use the following:

You don’t have to install pip , but you still have to use it to install other items.

Answering your comment, run the pip install again, this time with a sudo . You should see the following message:

Or something of the likes. Then run this:

If the import fails, go to the above directory and search for the files.

ImportError: No module named requests

Whenever I try to import requests , I get an error saying No module Named requests .

The error I get:

26 Answers 26

Requests is not a built in module (does not come with the default python installation), so you will have to install it:

OSX/Linux

Use $ pip install requests (or pip3 install requests for python3) if you have pip installed. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)

Alternatively you can also use sudo easy_install -U requests if you have easy_install installed.

Alternatively you can use your systems package manager:

For centos: yum install python-requests For Ubuntu: apt-get install python-requests

Windows

Use pip install requests (or pip3 install requests for python3) if you have pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)

Читайте также:  Линукс как поставь сервер

Alternatively from a cmd prompt, use > Path\easy_install.exe requests , where Path is your Python*\Scripts folder, if it was installed. (For example: C:\Python32\Scripts )

If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages )

mirsovetov.net

Андрощук Александр, ИТ решения, советы, заметки…

ImportError: No module named requests

Задача: При попытке подключить модуль requests (import requests) получил сообщение об ошибке: No module named requests. Нужно установить модуль requests

Инструменты: python2, python3, pip

Решение: Дело в том, что модуля requests нет в базовой инсталяции python’a. Его нужно устанавливать дополнительно. Рассмотрим команды, для установки модуля requests под разные операционные системы:

Если у Вас есть установлен pip, тогда выполните команду, которая установит пакет requests

pip3 install requests

Если у Вас есть желание установить пакет вручную, Вы можете скачать эту библиотеку, и розархивировать в папку

\Lib\site-packages . (Например: C:\Python\Lib\site-packages)

Чтобы установить пакет requests в Visual Studio Code — я использовал следующую команду:

Если у Вас установлен pip — выполните команду (Python2):

sudo pip3 install requests

Если у Вас есть установлен easy_install, тогда для него будет команда:

Для установки — выполним команду:

sudo apt-get install python-requests

sudo apt-get install python3-requests

ImportError: No module named requests — Python

I get an error message when I run the following line of code

Here is the error message

Based on what I’ve seen from other posts, the common reason for the problem is individuals download the requests module but have not installed it. I downloaded the tarball, unzipped it and installed the setup.py file via the computer command line. There is a requests-2.4.0-py2.7.egg folder in the Python27/Lib/site-packages folder.

Читайте также:  При запуске windows нет строки пуск

3 Answers 3

For Windows, install pip. You’ll probably need other packages later on, so it will pay off to have a proper package manager. Here is the documentation: https://pip.pypa.io/en/latest/index.html

You might actually be missing certifi module.

Overview: From your error stack trace, it appears that you are using Windows platform and have the native windows Python installation. So I will stick to Windows instructions here. But since I have Cygwin based python installation, I will provide here cygwin-based steps to resolve your issue.

However, you can very easily use these steps on the Windows command prompt as well, by installing pip or easy_install , pre-built binary, or source code.

Windows-Cygwin-Pip way:

  1. Add the directory that hosts python executable to your environment’s PATH variable. Instructions here
  2. Get pip to easily install new python packages. Best way is to download get-pip.py in cygwin’s home directory and run python get-pip.py in cygwin bash shell command prompt. Detailed and Alternative instructions here
  3. Run pip install requests in the cygwin bash shell. It will install requests and certifi packages, which results in results , requests-2.4.0.dist-info , certifi , and certifi-14.05.14-py2.7.egg-info in the /lib/site-packages folder.
  4. Run python and execute your original line of code import requests . It will run without errors.

Alternatives Ways to Installing a New Package: There are several other alternatives of downloading this requests package, or for that matter any new python package. These include:

  1. Getting easy_install in Cygwin and Running easy_install requests . Get easy_install in cygwin by installing setuptools package or by following instructions here.
  2. Downloading a pre-built binary available here. And running it as executable. It will automatically install the module under the latest python installation available in windows registry.
  3. Downloading source code for requests from Github into the home directory and Running python setup.py install

Python-Requests Installation Doc: There is a brief list of ways to install requests available on the original python-requests project website as well. See here.

Оцените статью