Jupyter startup error ImportError: DLL load failed while importing error

The command line starts jupyter and reports an error

Using cmd, jupyter notebookan error occurs after entering:

ImportError: DLL load failed while importing error: 找不到指定的模块。
Of course, first of all, the premise of this error is that the environment variable has been added.

The reason should be an environmental problem. There are other versions of Python installed locally, and the Python version selected when installing Anaconda is inconsistent with the local one. Start it through Powershell. There is (base) in the figure below, and you can find that the Python virtual environment is used here.

solve:

Use jupyter's PowerShell to open it.
Please add a picture description
Please add a picture description
At this point, the default browser should open automatically http://localhost:8888/tree, and you can find that jupyter has been successfully started.

Because of the virtual environment used by Powershell here, if you don’t use Powershell, you can use the command line directly, first activate the virtual environment:Please add a picture description


Modify jupyter default location

Using jupyter's PowerShell, open and typejupyter notebook --generate-config

(base) PS C:\Users\john> jupyter notebook --generate-config
Overwrite C:\Users\john\.jupyter\jupyter_notebook_config.py with default config? [y/N]n
(base) PS C:\Users\john>

You can see the configuration path: C:\Users\john\.jupyter\jupyter_notebook_config.py, enter the file and modify the configuration

Find "The directory to use for notebooks and kernels", uncomment "c.NotebookApp.notebook_dir", and change it to the path you want to customize, such as my "D:\CodeTest":

## The directory to use for notebooks and kernels.
#  Default: ''
c.NotebookApp.notebook_dir = 'D:\CodeTest'

Windows shortcut modification

Go to "Properties" - "Target" of the "Jupyter Notebook (anaconda3)" icon, delete the variables in the target ( , "%USERPROFILE%"including the preceding space), and only the file path name remains, for example:

C:\softwares\anaconda3\python.exe C:\softwares\anaconda3\cwp.py C:\softwares\anaconda3 C:\softwares\anaconda3\python.exe C:\softwares\anaconda3\Scripts\jupyter-notebook-script.py

After modification, start jupyter notebook to check whether there is a generated file under the custom path.


Configuration in Pycharm

进入 “File-Settings-Jupyter-Jupyter Servers”,

For "Python interpreter", choose python.exe in the location where Anaconda is installed locally, and the port can not be changed, but if you want to open another jupyter in the browser, port 8888 may be used by default.
Please add a picture description

Guess you like

Origin blog.csdn.net/qq_31362767/article/details/123649644