jupyer 切换环境
先在conda中切换到有pytorch的环境中
conda activate pytorch
安装
jupyterpip install jupyter
安装
ipykernelpip install ipykernel
设置环境
python -m ipykernel install --user --name 环境名 --display-name 环境名- 第一个name后是要写一个环境的名称,第二个name后是Notebook中显示的环境名称。
运行
jupyter notebookjupyter notebook- 不需要切换到pytorch环境中输入
在 jupyter中新建的时候选择自己需要的环境
设置中文
- 在jupyter中新建一个文件
- 输入
!pip install jupyterlab-language-pack-zh-CN - 提示
Successfully installed jupyterlab-language-pack-zh-CN-3.6.post0成功 - 重启
如果不好用需要进
用户环境变量添加- 选择新建,弹出的选项卡中,变量名为:
LANG变量值:zh_CN.UTF8
- 选择新建,弹出的选项卡中,变量名为:
设置工作目录
首先在命令行输入以下命令:
jupyter notebook --generate-config
- 随后会获得jupyter_notebook_config.py这个配置文件的路径
C:\Users\用户名\.jupyter,在文件夹中找到这个配置文件,然后点进去编辑。 - 找到这样一行代码:
# c.NotebookApp.notebook_dir ='' - 更改为:
c.NotebookApp.notebook_dir = 'D:\\jupter_notebook' - 而
D:\\jupter_notebook就是以后的工作目录了。 - 再次打开
jupyter notebook。
jupyter notebook 引入torch报错

需要Cython才能使pytorch工作:
pip3 install Cython
可能是在site-packages/torch中有一个名为_C.cpython-37m-x86_64-linux-gnu.so的库,该库提供共享对象_C,并且需要Cython。 PyCharm提供Cython支持,而Jupyter环境则不提供。
