需要指定版本和镜像时
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==2.2.0
为什么有镜像
在pip安装包时,包要从服务器上下载到本地后安装,不指定镜像时会选择国外的服务器,速度较慢,指定国内服务器后,速度较快,上面的镜像为清华源
设置永久镜像
在%APPDATA%\pip\pip.ini
$HOME/.config/pip/pip.conf
下建立文件夹pip,在内创建pip.ini,输入以下内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
https://pip.pypa.io/en/stable/user_guide/
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
Pip
pip install tensorflow==2.2.0
python3 -m pip install tensorflow==2.2.0
pip freeze > requirements.txt
pip install -r requirements.txt
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
conda config --set show_channel_urls yes
envs
conda activate base
conda deactivate
conda create --name your_env_name
conda create --name your_env_name python=3.5
conda create --name your_env_name python=3.5 numpy scipy
conda info --envs
conda env list
conda remove --name your_env_name --all
package
conda list
conda list jupyter*
conda install
conda install package -c anaconda
conda install package --force-reinstall
conda remove package_name
conda update package_name
conda search package_name
conda search package_name --channel https://conda.anaconda.org/<channel-name>/
# original conda url https://conda.anaconda.org/<channel-name>/
conda update –-all
config
conda config --show
conda clean -p //删除没有用的包
conda clean -t //删除tar包
conda clean -y --all //删除所有的安装包及cache
add kernel
conda install -c conda-forge jupyterlab
conda install ipykernel # base下
conda create -n <env_name> python=3.7
conda activate <env_name>
conda install --yes --file requirements.txt
conda env export > freeze.yml
conda env create -f freeze.yml
conda install ipykernel
python -m ipykernel install --user --name <env_name> --display-name "<display_name>"
conda deactivate
jupyter kernelspec list
jupyter kernelspec remove <kernel_name>
add R kernel
install.packages('IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation
jupyter labextension install @techrah/text-shortcuts # for RStudio’s shortcuts
jupyter lab extension
jupyter labextension list
install jupyterlab_code_formatter
conda install -c conda-forge jupyterlab_code_formatter
jupyter labextension install @ryantam626/jupyterlab_code_formatter@1.2.0
你可以使用pyright mypy pytype pyre
pandoc —standalone —self-contained —css sssimonyang.css 暑假生存录1.md —output 暑假生存录1.html
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all" # 返回全部显示
# 也可以在!ipython profile create后 C:\Users\sssimonyang\.ipython\profile_default\ipython_config.py 添加c.InteractiveShell.ast_node_interactivity = 'all'
!ipython profile create
[ProfileCreate] Generating default config file: 'C:\\Users\\sssimonyang\\.ipython\\profile_default\\ipython_config.py'
[ProfileCreate] Generating default config file: 'C:\\Users\\sssimonyang\\.ipython\\profile_default\\ipython_kernel_config.py'
[ProfileCreate] Generating default config file: '/slst/home/yangjk/.ipython/profile_default/ipython_config.py'
[ProfileCreate] Generating default config file: '/slst/home/yangjk/.ipython/profile_default/ipython_kernel_config.py'
修改使用的shell
c.ServerApp.terminado_settings = {‘shell_command’: [‘C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe’]}
个人未设置成功
IPython 魔法命令 https://ipython.readthedocs.io/en/stable/interactive/magics.html
reset # 删除所有变量
https://juejin.cn/post/6844904056020975629
% matplotlib inline
% matplotlib notebook
from IPython.display import Image
Image(filename = "img/picture.png")
Image(url = '')
jupyter从指定位置启动修改
jupyter notebook --generate-config
Writing default config to: C:\Users\sssimonyang\.jupyter\jupyter_notebook_config.py
Writing default config to: /slst/home/yangjk/.jupyter/jupyter_notebook_config.py
jupyter lab --generate-config
Writing default config to: C:\Users\sssimonyang\.jupyter\jupyter_lab_config.py
jupyter --config-dir
C:\Users\sssimonyang\.jupyter\jupyter_notebook_config.py
c.NotebookApp.notebook_dir = 'D:\\sssimonyang\\projects\\jupyter_lab'
C:\Users\sssimonyang\.jupyter\jupyter_lab_config.py
c.ServerApp.root_dir = 'D:\\sssimonyang\\projects\\jupyter_lab'
jupyter nbconvert --to markdown .\notes\python\python_basic.ipynb
jupyter nbconvert --to pdf .\notes\python\python_basic.ipynb
sns loadataset 问题
在C:\Users\sssimonyang处
git clone https://github.com/mwaskom/seaborn-data
a=2
install jupyterlab extension jupyterlab_code_formatter
I was using JupyterLab < 3.0.0
jupyter labextension install @ryantam626/jupyterlab_code_formatter
jupyter labextension list
JupyterLab v2.2.6
Known labextensions:
app dir: C:\ProgramData\Anaconda3\share\jupyter\lab
@ryantam626/jupyterlab_code_formatter v1.3.8 enabled ok
install package of corresponding version
conda install jupyterlab_code_formatter=1.3.8
then:
jupyter serverextension enable --py jupyterlab_code_formatter
if error:
from jupyter_server.base.handlers import APIHandler
ModuleNotFoundError: No module named 'jupyter_server'
do
conda install -c conda-forge jupyter_server
%ls
驱动器 D 中的卷没有标签。
卷的序列号是 D806-799C
D:\sssimonyang\projects\jupyter_lab\notes\python 的目录
2021/04/09 21:27 <DIR> .
2021/04/09 21:27 <DIR> ..
2021/04/09 20:54 <DIR> .ipynb_checkpoints
2021/04/09 21:07 36,882 python_advance.ipynb
2021/04/09 21:24 47,772 python_basic.ipynb
2021/03/20 21:08 9,346 python_config.ipynb
2021/04/09 21:23 250,135 python_data_analysis.ipynb
2021/04/09 20:19 792 python_ipython.ipynb
2021/04/09 21:27 3,844 python_notes.md
2021/04/09 21:27 15,695 python_package.ipynb
2021/04/09 21:14 10 some.txt
8 个文件 364,476 字节
3 个目录 54,786,064,384 可用字节
from IPython.display import Image
Image(url = '')
%load_ext autoreload
%autoreload 2