0%

python conda 环境安装配置

conda安装配置

官网下载合适版本
‘’’
https://repo.anaconda.com/archive/
‘’’
配置环境变量后,conda init
每次打开终端不默认激活conda: conda config --set auto_activate_base False
conda list 查看base环境中的所有包
pip升级最新版本:
python -m pip install –upgrade pip
换源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

conda相关命令

创建新环境命名python311

1
conda create -n python311 python=3.11

配置jupyter notebook 远程访问

生成配置文件:

1
jupyter notebook --generate-config 

一般保存在~/.jupyter/jupyter_notebook_config.py
可用 jupyter notebook password 设置密码
设置notebook自动补全

1
2
3
4
5
6
pip3 install jupyter-tabnine
conda install -c conda-forge jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension install --py jupyter_tabnine
jupyter nbextension enable jupyter_tabnine --py
jupyter serverextension enable --py jupyter_tabnine

运行图片相关代码报错:tesseract not found

1
apt install tesseract-ocr

selenium包使用

pip install pyvirtualdisplay selenium
apt install chromium-driver xvfb

xvfb-run python test.py

google-chrome安装

1
2
3
4
5
6
7

sudo apt update && sudo apt upgrade
sudo apt install software-properties-common apt-transport-https ca-certificates curl -y
curl -fSsL https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/google-chrome.gpg >> /dev/null
echo deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main | sudo tee /etc/apt/sources.list.d/google-chrome.list
apt update
apt install google-chrome-stable