9

how to export django project dependency

 3 years ago
source link: http://jeffsui.github.io/2020/09/15/how-to-export-django-project-dependency/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如何导出django项目依赖第三方库

d000baa1cd11728bf4f9b275c0fcc3cec2fd2c94.jpg

使用pip freeze 导出

针对大部分使用virtualenvvenvpipenv 虚拟环境的项目而言,导出第三方依赖很容易,运行下面的命令即可

pip freeze > requirements.txt

非虚拟环境如何导出项目依赖

安装 pipreqs

pip install pipreqs

进入项目根目录,使用下面的指令

1
pipreqs ./

出现的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
D:\code\django_blog\mysite>pipreqs ./
Traceback (most recent call last):
File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python38\Scripts\pipreqs.exe\__main__.py", line 9, in <module>
File "c:\python38\lib\site-packages\pipreqs\pipreqs.py", line 470, in main
init(args)
File "c:\python38\lib\site-packages\pipreqs\pipreqs.py", line 406, in init
candidates = get_all_imports(input_path,
File "c:\python38\lib\site-packages\pipreqs\pipreqs.py", line 122, in get_all_imports
contents = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 403: illegal multibyte sequence

添加命令行参数 encoding=utf-8

1
pipreqs ./ --encoding=utf-8

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK