在python项目中,需要requirements文件来记录项目所依赖的包和版本
生成requirements
sudo pip freeze > requirements.txt
如果报错:
The directory '/home/python/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
命令改成:
sudo -H pip freeze > requirements.txt
创建依赖的环境
pip install -r requirements
pip list 和pip freeze 是有区别的,我认得理解是pip list 展示的是所有的安装包,而pip freeze 展示的是需要安装的install安装包,因为有些安装包是自带的,原来就有,比如pip。