python項(xiàng)目下生成requirements.txt方法
一、使用pip freeae
pip freeze > requirements.txt
該命令存在局限:
該命令只會(huì)生成通過pip install 安裝的包
如果沒有創(chuàng)建Python的虛擬環(huán)境virtualenv,該命令會(huì)將環(huán)境中所有的包都輸出到requirements.txt文件,不管你當(dāng)前的Project有沒有用到這些包
二、使用pipreqs
Pipreqs 只會(huì)統(tǒng)計(jì)項(xiàng)目使用的包
2.1、安裝pipreqs
pip install pipreqs
2.2、使用方法
pipreqs "目錄" #在目錄下生成requirements.txt
2.3、特殊說明
2.3.1、Mac 下沒法使用
pipreqs zsh: command not found: pipreqs
沒有找到使用辦法
2.3.2、Linux 使用報(bào)錯(cuò)
pipreqs ./
Traceback (most recent call last):
File "/usr/bin/pipreqs", line 7, in <module>
from pipreqs.pipreqs import main
File "/usr/lib/python2.7/site-packages/pipreqs/pipreqs.py", line 51, in <module>
from pipreqs import __version__
ImportError: cannot import name __version__解決辦法,更換pipreqs版本
# 查看可安裝版本
pip install pipreqs==100
You are using pip version 7.1.0, however version 22.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pipreqs==100
Could not find a version that satisfies the requirement pipreqs==100 (from versions: 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.7, 0.2.8, 0.2.9, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.4.10, 0.4.11)
No matching distribution found for pipreqs==100
# 選擇某一版本安裝
pip install pipreqs==0.4.0
# 查看能否使用
pipreqs --help
pipreqs - Generate pip requirements.txt file based on imports
Usage:
pipreqs [options] <path>
Options:
--use-local Use ONLY local package info instead of querying PyPI
--pypi-server Use custom PyPi server
--proxy Use Proxy, parameter will be passed to requests library. You can also just set the
environments parameter in your terminal:
$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="https://10.10.1.10:1080"
--debug Print debug information
--encoding <charset> Use encoding parameter for file open
--savepath <file> Save the list of requirements in the given file
--force Overwrite existing requirements.txt2.3.3、Windows下使用
pipreqs "目錄" --encoding=utf8
三、更換環(huán)境后安裝requirements.txt
pip install -r requirements.txt
到此這篇關(guān)于python項(xiàng)目下生成requirements.txt方法的文章就介紹到這了,更多相關(guān)python requirements.txt內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- python生成requirements.txt的兩種方法
- 詳解python中requirements.txt的一切
- python?中的requirements.txt?文件的使用詳情
- python導(dǎo)出requirements.txt的幾種方法總結(jié)
- python生成requirements.txt文件的兩種方法
- Python pip通過requirements.txt 文件安裝依賴
- Python如何生成requirements.txt
- Python?requirements.txt的具體使用
- python生成requirements.txt文件的推薦方法
- python項(xiàng)目中requirements.txt的用法實(shí)例教程
- Python requirements.txt使用小結(jié)
相關(guān)文章
python實(shí)現(xiàn)回旋矩陣方式(旋轉(zhuǎn)矩陣)
今天小編就為大家分享一篇python實(shí)現(xiàn)回旋矩陣方式(旋轉(zhuǎn)矩陣),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12
在Python的Tornado框架中實(shí)現(xiàn)簡單的在線代理的教程
這篇文章主要介紹了在Python的Tornado框架中實(shí)現(xiàn)簡單的在線代理的教程,代理功能是一個(gè)常見的網(wǎng)絡(luò)編程實(shí)現(xiàn),需要的朋友可以參考下2015-05-05
Pycharm同步遠(yuǎn)程服務(wù)器調(diào)試的方法步驟
這篇文章主要介紹了Pycharm同步遠(yuǎn)程服務(wù)器調(diào)試,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11
Django動(dòng)態(tài)展示Pyecharts圖表數(shù)據(jù)的幾種方法
本文主要介紹了Django動(dòng)態(tài)展示Pyecharts圖表數(shù)據(jù)的幾種方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-08-08
python實(shí)現(xiàn)的批量分析xml標(biāo)簽中各個(gè)類別個(gè)數(shù)功能示例
這篇文章主要介紹了python實(shí)現(xiàn)的批量分析xml標(biāo)簽中各個(gè)類別個(gè)數(shù)功能,涉及Python針對xml文件的遍歷、讀取、解析等相關(guān)操作技巧,需要的朋友可以參考下2019-12-12
Python信息處理庫Talon自動(dòng)抽取簽名信息
這篇文章主要為大家介紹了Python信息處理庫Talon自動(dòng)抽取簽名信息實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01
pycharm運(yùn)行程序時(shí)出現(xiàn)Run‘python tests for XXX.py‘問題及
這篇文章主要介紹了pycharm運(yùn)行程序時(shí)出現(xiàn)Run ‘python tests for XXX.py‘問題及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08

