본문 바로가기

Python/pip

[Python] pip 설치, 업그레이드 (Windows)

반응형

 

 

 

pip 버전 확인

pip --version
pip -V

 

 

 

pip 업그레이드

python -m pip install --upgrade pip

 

 

python -m 에서 -m 의 뜻

-m mod : run library module as a script (terminates option list)

 

경로 출력

python -m site

 

 

Site Packages가 설치되어 있는 경로를 출력하는 방법

python -m site --user-site

 

 

 

pip로 설치 방법

pip install flask

# 버전 지정
pip install flask==1.1.1

# 업그레이드
pip install -U flask
pip install --upgrade flask

pip install --force-reinstall flask

 

 

 

requirements.txt 생성

pip freeze > requirements.txt

 

 

 

requirements.txt 파일 이용해서 설치 방법

pip install -r requirements.txt
pip install --requirement requirements.txt

python -m pip install -r requirements.txt

# upgrdae
pip install -U -r requirements.txt

 

 

 

requirements.txt 파일 이용해서 삭제 방법

pip uninstall -r requirements.txt

 

 

 

requirements.txt 예시

  • #는 주석처리
  • 최신 버전으로 설치됨
  • ==, >, >=, <, <= 로 특정 버전 지정 가능
# This is a comment, to show how #-prefixed lines are ignored.
# It is possible to specify requirements as plain names.
pytest
pytest-cov
beautifulsoup4

# The syntax supported here is the same as that of requirement specifiers.
docopt == 0.6.1
requests [security] >= 2.8.1, == 2.8.* ; python_version < "2.7"
urllib3 @ https://github.com/urllib3/urllib3/archive/refs/tags/1.26.8.zip

# It is possible to refer to other requirement files or constraints files.
-r other-requirements.txt
-c constraints.txt

# It is possible to refer to specific local distribution paths.
./downloads/numpy-1.9.2-cp34-none-win32.whl

# It is possible to refer to URLs.
http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl

 

Click==7.0
cx-Oracle==7.2.0
Flask==1.1.1
Flask-RESTful==0.3.8
Flask-SQLAlchemy==2.5.1
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
matplotlib==3.1.1
# numpy==1.19.1
openpyxl==3.0.0
pandas==0.24.2
Pillow==7.2.0
pyodbc==4.0.30
# pyOpenSSL==19.0.0
python-docx==0.8.10
pywin32==302
requests==2.21.0
scipy==1.5.2
SQLAlchemy==1.4.8
Werkzeug==0.15.5
xlrd==1.2.0
XlsxWriter==1.2.9

 

 

 

 

,(컴마)로 구분하면 2개의 조건을 AND로 지정

# 1.0이상 and 2.0이하의 버전 설치
package >= 1.0, <=2.0

 

 

 

문제) pip uninstall -r requirements.txt 로 설치 했는데 현재 환경에 반영 되지 않는다..

 

 

 

 

https://pip.pypa.io/en/latest/cli/pip_install/#pip-install

 

pip install - pip documentation v22.3.dev0

py -m pip install --upgrade SomePackage Note This will guarantee an update to SomePackage as it is a direct requirement, and possibly upgrade dependencies if their installed versions do not meet the minimum requirements of SomePackage. Any non-requisite up

pip.pypa.io

 

 

https://note.nkmk.me/python-pip-install-requirements/

 

Python, pipでrequirements.txtを使ってパッケージ一括インストール | note.nkmk.me

Pythonのパッケージ(ライブラリ)をpipで管理している場合、設定ファイルrequirements.txtを使って指定のパッケージを指定のバージョンで一括インストールすることができる。User Guide — pip 9.0.1

note.nkmk.me

 

반응형

'Python > pip' 카테고리의 다른 글

[Python] pip, pipenv install SSLError  (0) 2022.07.25
[Python] pip 업그레이드 명령어 (Windows)  (0) 2019.07.16