1.Anaconda3:
conda create -n 環境名 numpy python=3.6 #後面可以接其他包 =用來指明版本
conda list # 查看安裝包列表
conda --version # 查看版本號
conda info -e #用於查看擁有的環境
conda remove -n 虛擬環境名稱 --all #刪除對應環境
conda create –n 新名 –-clone 舊名 #用於克隆,改名也蠻好的
Anaconda3安裝完成之後,以管理員身份運行anaconda propmt
更新所有的庫
conda update --all
若Win10安裝Anacondad3之後沒有pip則執行:
# 以管理員身份運行
cd C:\ProgramData\Anaconda3\Scripts
easy_install.exe pip
python -m pip install --user --upgrade pip
2. 安裝
python -m pip install --user --upgrade pip
conda create -n ai pip python=3.6
conda activate ai
conda deactivate
(ai)xx> pip install torch===1.3.1 torchvision===0.4.1 -f torch-1.3.1-cp36-cp36m-win_amd64.whl
import torch
import torchvision
print(torch.__version__)
print(torch.cuda.is_available()) # 返回True, 則PyTorch的GPU安裝成功
pip install Pillow==6.1 # ImportError: cannot import name 'PILLOW_VERSION'
https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.0.0-cp36-cp36m-win_amd64.whl
pip install tensorflow-gpu==2.0.0 -f d:\ztools\tensorflow_gpu-2.0.0-cp36-cp36m-win_amd64.whl
pip install --upgrade tensorflow #升級到最新版本 (不支持GPU)
pip install –upgrade tensorflow-gpu #升級到最新版本 (支持GPU)
import tensorflow as tf;
print(tf.__version__) # 獲取TensorFlow版本號
import tensorflow as tf;
tf.test.is_built_with_cuda() #檢測cuda 返回true或者false
tf.test.is_gpu_available() # 檢測gpu 返回true或者false
# 如果兩個都是true 那麼gpu就安裝好了
# FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)])
pip install numpy==1.16.0
pip install opencv-python==4.1.2.30 # only install main modules
pip install opencv-contrib-python==4.1.2.30 # install both main and contrib modules
import cv2
print(cv2.__version__)
3. 問題解決
3.1 安裝Anaconda3
3.1.1 Install Microsfot VSCode failed
解決方案:在/anaconda3/pkgs/vscode_inst.py中的def haveInternet():中增加允許重定向allow_redirects=True
def haveInternet():
try:
r = requests.head(VSCODE_ENDPOINT, timeout=5, allow_redirects=True)
assert r.status_code == 200
return True
except Exception as e:
log.exception('haveInternet')
return False
4. 修改Anaconda中Jupyter Notebook默認路徑
jupyter notebook --generate-config
修改jupyter_notebook_config.py
c.NotebookApp.notebook_dir = 'E:\Jupyter'