碎点篇——AI学习python库安装一套带走
AI学习python库安装一套带走
指定源下载:
pip install page_name -i https://pypi.tuna.tsinghua.edu.cn/simple
如:
pip install tqdm -i https://pypi.tuna.tsinghua.edu.cn/simp
///////////////////////////////////////////////////////////////////////////////////////
安装库的时候,可以用 conda 命令,就不用 pip 命令,因为, conda 会比 pip 的 库要快些
///////////////////////////////////////////////////////////////////////////////////////
更新 pip 版本:
python -m pip install --upgrade pip
在conda环境下,查看python版本:
conda search --full-name python
conda search --full-name tensorflow-gpu
查看conda 版本:
conda --version
查看当前环境中已安装的所有包:
conda list
列出所有的环境:
conda env list
创建虚拟环境,并命名为daozhang,指定解释器为python3.6
conda create -n daozhang python=3.6
进入conda的虚拟环境:
activate daozhang
linux 下进入虚拟环境:
source activate daozhang
关闭窗口:(或退出)
exit()
第一次进入虚拟环境,先更新pip:
python -m pip install --upgrade pip
安装第三方库:
conda install packege_name
或 pip install packege_name
卸载第三方库:
conda remove packege_name
或 pip uninstall packege_name
将当前环境的库信息导出为yaml文件:
conda env export > environment.yaml
导入环境
conda env create -f environment.yaml
删除环境(daozhang(your env name))
conda remove -n daozhang --all
//////////////////////////////////////////////////////////
conda 环境更行 python 版本:
conda install python==3.7
在conda的环境下安装TensorFlow
conda install tensorflow (安装cpu版本)
conda install tensorflow-gpu (安装gpu版本)
conda install tensorflow==1.7.0 (安装cpu版本,指定版本)
conda install tensorflow-gpu==1.13.1 (安装gpu版本,指定版本)
也可以用 pip install 的方法
在conda的环境下安装 sklearn:
conda install scikit-learn
conda 环境下安装 skimage:
pip install scikit_image
在conda的环境下安装 jupyter notebook:
conda install jupyter notebook
查看 gpu 资源:
nvidia-smi
动态查看 gpu 资源:
watch -n 0.5 nvidia-smi
在conda的环境下安装labelme
conda install pyqt
conda install pillow
pip install labelme
安装好后,直接输入命令: labelme 可以开启labelme 工具
在conda的环境下安装easydict
pip install easydict
或: conda install -c chembl easydict
在conda环境下安装显示循环的进度条的库tqdm
pip install tqdm
在conda环境下安装pytesseract:
pip install pillow #一个python的图像处理库,pytesseract依赖
pip install pytesseract
在conda环境下安装 wand: (用于将pdf->jpeg)
pip install wand
在conda环境下安装 pyocr:
pip install pyocr
在conda环境下安装 imutils:
pip install imutils
在conda环境下安装 cv2:
pip install opencv-python
查看opencv的版本:
import cv2
print(cv2.__version__)
在conda环境下安装 matplotlib:
pip install matplotlib
在conda环境下安装 jieba:
pip install jieba
在conda环境下安装 pandas:
pip install pandas
在conda环境下安装 pypinyin:
pip install pypinyin
在conda环境下,安装shapely:
pip install geos
conda install shapely
在conda环境下安装 glog:
pip install glog
在conda环境下安装 requests:
pip install requests
在conda环境下安装 web:
pip install web.py==0.40-dev1
在conda环境下安装 flask:
pip install flask
//////////////////////////////////////////////////////////////////////////////
以下这个,尽量不要装,会把 tensorflow-1.13.1 版本升级为 2.0.0 版本,会有很多麻烦
在conda环境下安装 tensorflow-serving: (要求tensorflow 1.14 版本或以上)
pip install tensorflow-serving-api
/////////////////////////////////////////////////////////////////////////////
在conda环境下安装 wordninja:
pip install wordninja
在conda环境下安装 keras:
pip install keras
在conda环境下安装 wget:
pip install wget
在conda环境下安装 lmdb:
pip install lmdb
在conda环境下安装 pytorch:
pip install mxnet-cu101 -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.douban.com
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.douban.com torch===1.2.0 torchvision===0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
安装 mxnet 的时候,需要和 cuda 的版本对应。如果 CUDA 10.0 则安装 mxnet-cu100;不然运行时会有版本冲突问题出现
在安装的时候,第二个命令下载的内容比较大,容易超时错误,在这里可以取巧:
下载的时候显示:
Downloading https://download.pytorch.org/whl/cu100/torch-1.2.0-cp36-cp36m-win_amd64.whl (750.2MB)
这时候,可以搜索 torch-1.2.0-cp36-cp36m-win_amd64 文件,看看,文件是下载在哪里,然后
用迅雷下载后,将文件放置在该位置
在安装的时候,可能会改变 numpy 的版本,导致 import torch 的时候,会报错:
from torch._C import *
ImportError: numpy.core.multiarray failed to import
同时,会发现,import numpy 也会报错:
ImportError: Something is wrong with the numpy installation.
这是,只要 pip uninstall numpy, 之后, 再 pip install numpy==1.16
这样,再次 import numpy 的时候,不再报错
而且,发现 import torch 也正常了。
conda 环境下安装 tensorboardX:
pip install tensorboardX
conda 环境下安装 mxnet:
conda install mxnet
conda 环境下安装 dlib:
先安装好 cmake,这个主要用来编译dlib
sudo apt install cmake
然后安装 dlib
pip install dlib