需要指定版本和镜像时
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.0python3 -m pip install tensorflow==2.2.0pip freeze > requirements.txtpip install -r requirements.txt
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/conda config --set show_channel_urls yes
envs
conda activate baseconda deactivateconda create --name your_env_nameconda create --name your_env_name python=3.5conda create --name your_env_name python=3.5 numpy scipyconda info --envsconda env listconda remove --name your_env_name --all
package
conda listconda list jupyter*conda installconda install package -c anacondaconda install package --force-reinstallconda remove package_nameconda update package_nameconda search package_nameconda 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 --showconda clean -p //删除没有用的包conda clean -t //删除tar包conda clean -y --all //删除所有的安装包及cache
add kernel
conda install -c conda-forge jupyterlabconda install ipykernel # base下conda create -n <env_name> python=3.7conda activate <env_name>conda install --yes --file requirements.txtconda env export > freeze.ymlconda env create -f freeze.ymlconda install ipykernelpython -m ipykernel install --user --name <env_name> --display-name "<display_name>"conda deactivatejupyter kernelspec listjupyter kernelspec remove <kernel_name>
add R kernel
install.packages('IRkernel')IRkernel::installspec() # to register the kernel in the current R installationjupyter 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_formatterjupyter 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 InteractiveShellInteractiveShell.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 ImageImage(filename = "img/picture.png")Image(url = '')
jupyter从指定位置启动修改
jupyter notebook --generate-configWriting default config to: C:\Users\sssimonyang\.jupyter\jupyter_notebook_config.pyWriting default config to: /slst/home/yangjk/.jupyter/jupyter_notebook_config.pyjupyter lab --generate-configWriting default config to: C:\Users\sssimonyang\.jupyter\jupyter_lab_config.pyjupyter --config-dirC:\Users\sssimonyang\.jupyter\jupyter_notebook_config.pyc.NotebookApp.notebook_dir = 'D:\\sssimonyang\\projects\\jupyter_lab'C:\Users\sssimonyang\.jupyter\jupyter_lab_config.pyc.ServerApp.root_dir = 'D:\\sssimonyang\\projects\\jupyter_lab'jupyter nbconvert --to markdown .\notes\python\python_basic.ipynbjupyter 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 listJupyterLab v2.2.6Known 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 APIHandlerModuleNotFoundError: No module named 'jupyter_server'
do
conda install -c conda-forge jupyter_server
%ls
驱动器 D 中的卷没有标签。卷的序列号是 D806-799CD:\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_checkpoints2021/04/09 21:07 36,882 python_advance.ipynb2021/04/09 21:24 47,772 python_basic.ipynb2021/03/20 21:08 9,346 python_config.ipynb2021/04/09 21:23 250,135 python_data_analysis.ipynb2021/04/09 20:19 792 python_ipython.ipynb2021/04/09 21:27 3,844 python_notes.md2021/04/09 21:27 15,695 python_package.ipynb2021/04/09 21:14 10 some.txt8 个文件 364,476 字节3 个目录 54,786,064,384 可用字节
from IPython.display import ImageImage(url = '')%load_ext autoreload%autoreload 2
