본문 바로가기

데이터과학/Python

ImportError: No module named requests [Python 오늘의 에러]

반응형

단순한 문제인데, 생각보다 안풀려서 헛발질을 오래 했습니다. 

 

몇가지 중요한 사항을 놓치면, 아무리 pip install을 해도 해결되지 않는거 같습니다. 

 

가상환경

기본적으로 가상환경에서 python을 실행중이라면 가상환경(venv)안에 설치를 해주어야 합니다. 

 

C:에 설치를 하고, venv에서 찾으면 당연히 찾지를 못하는 결과입니다 .

(venv) C:\Users\username\Projects\venv\Scripts> pip install requests

 

pip에서 설치가 안될 경우 

git에서 다운로드해서 바로 설치하기 

 

git clone git://github.com/kennethreitz/requests.git
cd requests
python setup.py install

 

 

Installation of Requests — Requests 2.25.1 documentation

Installation of Requests This part of the documentation covers the installation of Requests. The first step to using any software package is getting it properly installed. $ python -m pip install requests To install Requests, simply run this simple command

docs.python-requests.org

 

환경설정

python의 여러버전이 설치되어 있는 경우, 환경변수 설정이 잘못되어 있으면, 

 

3.x에 설치된 requests를 2.x에서 찾고 있는 경우가 생깁니다. 

 

간단하게 환경변수 확인도 해봅시다. 

 

윈도우 > 시스템 환경변수 편집 > 환경변수(N) > 

환경변수 > Path
C:\Python39\Scripts\
C:\Python39

#사용자변수 > Path에 있는 python 관련 경로는 삭제합니다. 

 

반응형