Python

Last Edited Time
Feb 9, 2022 07:01 AM
date
Oct 19, 2018
slug
python
status
Published
tags
Python
Notebook
Command
summary
Python 学习记录
type
Post

install common packages

pip install jupyter -i https://mirrors.aliyun.com/pypi/simple
pip install tensorflow==1.15 -i https://mirrors.aliyun.com/pypi/simple/
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.11.0-py3-none-any.whl

create vertual envirnment

virtualenv --version
pip3 install -U virtualenv
virtualenv --no-site-packages venv
source venv/bin/activate
deactivate

using anaconda

# 取消默认激活 base 环境
conda config --set auto_activate_base false

# 查看系统中的所有环境
conda info -e

conda --version
conda upgrade --all
# 3.6 tensorflow 支持比较好
conda create -n learn python=3.6
conda activate learn
conda deactivate
conda remove -n learn --all

# install common used libraries
python3 -m pip install --upgrade pip
conda install -f matplotlib
conda install tensorflow
conda install numpy scipy pandas
conda install scikit-learn

Tensorflow

# 使用2.0中的v1兼容包来沿用1.x代码
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

# 不过不能解决 tf.contrib 不存在的问题
tf.contrib.layers.xavier_initializer