conda install package 和 pip install package 这两种方式优先使用哪一种都没关系,但需要考虑 package 调用顺序优先级以及避免重复安装,优先使用哪种就要一直保持,不能这次安装 package A 用 conda install 方式,下次安装 package B 用 pip install,如果经常这样安装 package 在以后调用的时候很可能报错。
在此我决定养成 优先conda,然后才是pip的安装习惯
conda换源
换清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
换回默认源
换回默认源:conda config --remove-key channels
conda虚拟环境相关指令
#查看conda虚拟环境
conda env list
#查看虚拟环境中conda安装的包
conda list
#conda激活环境
conda activate 环境名
#conda退出环境
conda deactivate
#conda删除虚拟环境
conda env remove -n 要删除的虚拟环境名
#conda创建虚拟环境
conda create -n 环境名 python=3.7
conda安装和pip安装常规指令
#conda安装包
conda install 包名
#conda卸载安装包
conda remove 包名
conda uninstall 包名
#pip安装
pip install 包名
pip uninstall 包名
#pip清华源安装
pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装numpy
conda install numpy=1.19.2
卸载 conda uninstall numpy
#安装pandas
conda install pandas=1.3.4
或者 pip install pandas
#安装sklearn
conda install scikit-learn
或者 pip install -U scikit-learn
#安装matplotlib
我上次尝试pip报错了,然后用conda安装
首先 conda search matplotlib 查看我的python版本对应的matplotlib
conda list 发现我的是python36,然后
conda install matplotlib=3.1.1 --channel conda-forge
安装成功
(比较慢,换上清华源还是很慢,但比默认源快,耐性等待,半个小时都是正常的)
pip install matplotlib (pip安装matplotlib 会出现各种兼容性问题,非常不建议)
问题:
1.反正3.7.1版本及以上,都会有问题(对应numpy2.0又会出现新的兼容性问题,numpy2.0不支持tensorflow2.4.0)
2.建议先安装matplotlib ,因为安装matplotlib 后,会把numpy包自动安装好,并把之前你装好的都自动卸载掉
#安装seabor
conda install seaborn
#安装RDKit
RDKit的安装比较复杂,去看RDkit专栏安装方法【RDKit】关于RDKit安装问题,python兼容性问题(最后有RDKit的正确安装方法)-CSDN博客
#安装IPython
conda install ipython
#安装xgboost
输入以下命令,用清华镜像。包从这里下载,速度比较快;否则,默认国外的镜像,下载速度慢,会导致安装失败
pip install xgboost -i https://pypi.tuna.tsinghua.edu.cn/simple
我项目环境对应各种包版本
我的经验关于安装包的顺序
1.matplotlib
2.pandas
3.numpy
tensorflow2.4.0推荐对应一系列包的版本
(一定要先配好numpy对应pandas,这个是基础,因为numpy一卸载,其他包都会被卸载)
pip install tensorflow-gpu2.4.0
matplotlib=3.5.2
numpy 1.19.2
pandas=1.3.4
scipy 1.4.1
opencv_python 4.2.0.34
tensorflow_gpu 2.4.0
tqdm 4.46.1
Pillow 8.2.0
h5py==2.10.0
pytorch 1.10.0推荐对应一系列包的版本
python 3.7.4
rdkit 2020.09.1
scikit-learn 1.0.2
torch 1.10.0
docopt 0.6.2
matplotlib 3.5.2
pandas 1.3.4
numpy 1.19.2
scipy 1.6.2
molshap的项目的环境配置
python = 3.7
rdkit = 2021.09.2
sklearn = 1.0.1
shap = 0.41.0
matplotlib=3.5.2
pandas=1.3.4
numpy 1.19.2
(一定要先配好numpy对应pandas,这个是基础,因为numpy一卸载,其他包都会被卸载)
三、
- Python (3.6.10)
- chemprop (0.0.2)
- Numpy (1.18.5)
- pandas (1.0.4)
- PyTorch (1.5.0)
- RDKit (2020.03.2)
- scikit-learn (0.23.1)
- tqdm (4.46.1)
- h5py (2.10.0; for writing/reading an HDF5 file with stored fingerprints)
- Optuna (1.5.0; for hyperparameter optimization)
- hickle (3.4.5; for saving/loading dictionaries in the bit and substructure analysis)
四、
streamlit==1.12.0
pandas==1.3.5
scikit-learn==1.0.2
padelpy==0.1.11
stmol==0.0.9
py3Dmol==1.8.1
rdkit-pypi==2022.3.5