1. pip与requirement.txt

requirement.txt内容,支持的写法如下

  1. -r base.txt # base.txt下面的所有包
  2. pypinyin==0.12.0 # 指定版本(最日常的写法)
  3. django-querycount>=0.5.0 # 大于某个版本
  4. django-debug-toolbar>=1.3.1,<=1.3.3 # 版本范围
  5. ipython # 默认(存在不替换,不存在安装最新版)

导出txt与从txt安装

  1. pip freeze > requirements.txt # 生成requirements.txt
  2. pip install -r requirements.txt # 从requirements.txt安装依赖

https://blog.csdn.net/weixin_42096901/article/details/89299017
比如下载 django 1.8.11版本和simplejson 3.14.0版本的包

那么就将所需的包写入 requirement.txt,那么我的requirement.txt内容就是:

django==1.8.11
simplejson==3.14.0

如果还需要其他的包可以依次写,注意一定要写清楚自己所需的版本号避免使用的时候出错。

例如:想将包放在\home\packs目录下

那么就在命令行窗口输入:pip download -d \home\packs -r requirement.txt
安装:pip install -f ./Envbag -r requirements.txt

注意:服务器环境一般都为linux 环境,所以我们下载所需包的时候最好使用自己的虚拟机或其他相同的环境来进行下载。


2. conda

创建conda环境[
conda create -n env_test python=3.5

](https://blog.csdn.net/qq_35959613/article/details/82386475)

  1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  2. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  3. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  4. conda config --set show_channel_urls yes


3. Pytorch


检查是否安装成功

  1. import torch
  2. print(torch.__version__)
  3. print(torch.cuda.is_available())