Article Directory
pip
View pip version
pip --version
Upgrade pip version
python -m pip install --upgrade pip
conda
Check which packages are installed by conda
conda list
View the packages installed in the virtual environment
conda list -n env_name
See which virtual environments currently exist
conda env list 或 conda info -e
Update conda version
conda update conda
Create a virtual environment
conda create -n env_name python=python_version
Activate the virtual environment
activate env_name
Add the virtual environment to the jupyter notebook kernel
1. Download jupyter notebook directly in the virtual environment and add it.
Step 1: Activate the virtual environment and download jupyter notebook in the virtual environment
activate env_name
pip install jupyter notebook
Step 2: Add the virtual environment to the notebook
python -m ipykernel install --user --name=(你想要该虚拟环境在kernel中显示的名字)
2. Method 1 is more troublesome, because you need to download jupyter notebook extra, but our anaconda has jn, so:
Step 1: Activate the virtual environment and download the ipykernel plug-in
activate env_name
(pip)conda install ipykerne
Step 2: Same as Step 2 in Method 1
python -m ipykernel install --user --name=(你想要该虚拟环境在kernel中显示的名字)
Close the virtual environment
deactivate env_name
Delete virtual environment
conda remove -n env_name --all
Delete the package in the virtual environment
conda remove -n env_name package_name
Install the package in a virtual environment
1.先activate env_name 在 pip install package_name
2.直接conda install -n env_name package_name
Update package
conda update -n env_name package_name
Delete package
conda remove -n env_name package_name
Check the version matching of keras and tensorflow
click here
jupyter
Upgrade jupyter notebook
pip install --upgrade jupyter
View all cores of jupyternotebook
jupyter kernelspec list
Delete a kernel
jupyter kernelspec remove kernel_name
View the currently used python version and python path in jupyter notebook
import sys
print(sys.version)
print(sys.executable)
Jupyter shortcut keys
Merge cell
shift ↑\↓(选中多个cell)
shift M
Split cell at cursor
ctrl + shift + -
Find code
esc + F
Hide\show output
esc+O
Common mistakes
Error one:
input sentence: pip install torch
report error: Module Not FoundError: No module named 'tools.nnwrap'
solve: pytorch official website , use the sentence provided by the official website
Error two:
input statement: conda create -n Keras python=python38
report error: PackagesNotFoundError: The following packages are not available from current channels: - python=python38
solve: it should beconda create -n Keras python=3.8
Error three: