티스토리 뷰
Stack Overflow 에 자주 검색 또는 등록되는 문제들을 정리하고 있습니다. 가장 높은 점수를 받은 Solution과 가장 최근에 업데이트 된 Solution 을 각각 정리하였습니다.
ImportError: No module named requests
가져오기 오류: 이름이 지정된 모듈 요청이 없습니다.
문제 내용
I tried importing requests
:
requests를 import하려고 했습니다.
import requests
But I get an error:
하지만 오류가 발생합니다.
ImportError: No module named requests
가져오기 오류: 이름이 지정된 모듈 요청이 없습니다.
높은 점수를 받은 Solution
Requests is not a built in module (does not come with the default python installation), so you will have to install it:
requests는은 기본 제공 모듈이 아니므로(기본 파이썬 설치와 함께 제공되지 않음) 설치해야 합니다.
OSX/Linux
OSX/리눅스
Python 2: sudo pip install requests
Python 2: sudo pip 설치 요청
Python 3: sudo pip3 install requests
Python 3: sudo pip3 설치 요청
if you have pip
installed (pip
is the package installer for python and should come by default with your python installation). 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)
pip이 설치되어 있는 경우(pip은 python용 패키지 설치 프로그램이며 python 설치 시 기본적으로 함께 제공되어야 함). pip이 설치되어 있지만 경로에 없는 경우 python-mpip 설치 요청(또는 python3에 대한 python3-mpip 설치 요청)을 사용할 수 있습니다.
Alternatively you can also use sudo easy_install -U requests
if you have easy_install
installed.
또는 easy_install이 설치된 경우 sudo easy_install -U 요청을 사용할 수도 있습니다.
Linux
리눅스
Alternatively you can use your systems package manager:
또는 시스템 패키지 관리자를 사용할 수 있습니다.
For centos: sudo yum install python-requests
센토스의 경우: sudoyum install python-requests
For Debian/Ubuntu Python2: sudo apt-get install python-requests
Debian/Ubuntu Python2의 경우: sudo apt-get install python-requests
For Debian/Ubuntu Python3: sudo apt-get install python3-requests
Debian/Ubuntu Python3의 경우: sudo apt-get install python3-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)
Pip이 설치되어 있고 Pip.exe가 Path Environment Variable에 추가된 경우 Pip 설치 요청(또는 python3의 경우 Pip3 설치 요청)을 사용합니다. pip이 설치되어 있지만 경로에 없는 경우 python-mpip 설치 요청(또는 python3에 대한 python3-mpip 설치 요청)을 사용할 수 있습니다.
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
)
cmd 프롬프트에서 > Path\easy_install.exe 요청을 사용합니다. 여기서 Path는 Python*\Scripts 폴더(설치된 경우)입니다(예: C:\Python32\스크립트)
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
)
수동으로 윈도우즈 시스템에 라이브러리를 추가하려는 경우 압축된 라이브러리를 다운로드하여 압축을 푼 다음 파이썬 경로의 Lib\site-packages 폴더에 저장할 수 있습니다(예: C:\Python27\Lib\site-packages)
From Source (Universal)
출처(범용)
For any missing library, the source is usually available at https://pypi.python.org/pypi/. You can download requests here: https://pypi.python.org/pypi/requests
누락된 라이브러리의 경우 소스는 일반적으로 https://pypi.python.org/pypi/에서 제공됩니다. 요청은 https://pypi.python.org/pypi/requests에서 다운로드할 수 있습니다.
On mac osx and windows, after downloading the source zip, uncompress it and from the termiminal/cmd run python setup.py install
from the uncompressed dir.
Macosx와 Windows에서 소스 zip을 다운로드한 후 압축을 풀고 압축되지 않은 dir에서 python setup.py 설치를 실행합니다.
(source)
(출처)
가장 최근 달린 Solution
Please try the following. If one doesn't work, skip to the next method.
다음을 시도해 보십시오. 하나가 작동하지 않으면 다음 방법으로 건너뜁니다.
pip install requests
or...
아니면...
pip3 install requests
or...
아니면...
python -m pip install requests
or...
아니면...
python3 -m pip install requests
or...
아니면...
python -m pip3 install requests
If all of these don't work, please leave a comment!
How does this work? Depending on the operating system you currently use, the pip command may vary or not work on some. These are the commands you may try in order for a fix.
이거 다 안 되면 댓글 달아주세요! 이것은 어떻게 작동하나요? 현재 사용 중인 운영 체제에 따라 pip 명령이 달라지거나 작동하지 않을 수 있습니다. 다음은 수정을 위해 시도할 수 있는 명령입니다.
출처 : https://stackoverflow.com/questions/17309288/importerror-no-module-named-requests
'개발 > 파이썬' 카테고리의 다른 글
"ImportError: Cannot import name X" 또는 "AttributeError" 를 어떻게 해결하나요? (0) | 2022.11.25 |
---|---|
다른 .py 파일에서 함수를 호출하려면 어떻게 해야 합니까? (0) | 2022.11.25 |
Attempted relative import in non-package 문제 수정 (0) | 2022.11.25 |
virtualenv에서 Python 3 사용 (0) | 2022.11.25 |
[구현] 주식 일별시세 크롤링하기 (6) | 2020.11.30 |