Miniconda
Miniconda是一个轻量级的Conda包管理器
安装包
所有安装包:repo.anaconda.com/miniconda
Linux: python3.8 Miniconda3 Linux 64-bit
python3.7 Miniconda3 Linux 32-bit
# 以前的版本没有ssh问题
wget https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh
配置
初始化终端:
~/miniconda3/bin/conda init
如果失败可以手动添加bin
目录。
echo "export PATH=\$PATH:/home/pi/miniconda3/bin" >> .bashrc
使用
新建环境
# 新建名称为test的环境
conda create --name test python=3.8 -y
# arm只能创建python=3.4的环境
conda create -n test python=3.4 -y
查看所有的环境
conda env list
使用环境
# 激活环境
conda activate test
source activate test # arm
# 退出当前环境
conda deactivate
source deactivate # arm
# 删除环境
conda remove -n test1 --all
rpi
armv7l: miniconda3-latest-linux-armv7l.sh
Berryconda3-2.0.0-Linux-armv7l.sh
arm版本的miniconda最高只能安装python3.4
,如果需要安装更高版本的python
,需要第三方conda,这里使用的是 berryconda,目前最高支持到python3.6
。
conda config --add channels rpi
conda create --name test python=3.6 -y
venv
python自带的虚拟环境模块
# 新建
python -m venv /path/venv_name
# 激活
source /path/venv_name/bin/activate
# 退出
deactivate
https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz
Pytorch
old version lib torch: https://github.com/pytorch/pytorch/issues/40961
Pytorch,选择对应cuda版本。
torch.version # PyTorch version
torch.version.cuda # Corresponding CUDA version
torch.backends.cudnn.version() # Corresponding cuDNN version
torch.cuda.get_device_name(0) # GPU type
jupyter notebook
ipykernel
通过ipykernel管理jupyter notebook的内核。
# 激活环境
activate env_name
# 安装ipykernel
pip install ipykernel
# 添加kernel
python -m ipykernel install --name env_name
# 删除内核
jupyter kernelspec remove kernelname
# 查看所有内核
jupyter kernelspec list
远程访问
生成密钥
# 通过ipython生成密码
ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[3]: 'xxxxxxxxxxxxxxxxxxxxxx'
# 生成配置文件,并添加如下配置
jupyter notebook --generate-config
c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.password = u'xxxxxxxxxxxxxxxxxxxxxx'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888
然后就可以通过[https://ip:8888远程访问`jupyter](https://ip:8888远程访问`jupyter/) notebook`
Donate me.
- Post link: https://sanzo.top/Default/python-env/
- Copyright Notice: All articles in this blog are licensed under unless otherwise stated.