將Python虛擬環境新增到Jupyter Notebook中
目的:將利用conda自定義的python虛擬環境新增到jupyter notebook中
建立虛擬環境:conda create -n snp python=3.8.3,並切換到當前虛擬環境下conda activate snp。
安裝ipykernel包:conda install ipykernel
新增到Jupyter中:python -m ipykernel install --name snp #後面的環境名字需要更換
重啟Jupyter,即可看到新增的虛擬環境
新環境新增成功
切換環境,測試程式碼(一直顯示“服務正在啟動,請等待”)的字樣,檢視命令列發現問題ImportError: DLL load failed while importing error: 找不到指定的模組。進行解決。詳細的錯誤程式碼如下:
[I 21:59:57.053 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "D:\Software\Anaconda3\envs\snp\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Software\Anaconda3\envs\snp\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
from .connect import *
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\ipykernel\connect.py", line 16, in <module>
import jupyter_client
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
from .connect import *
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
import zmq
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\__init__.py", line 55, in <module>
from zmq import backend
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "D:\Software\Anaconda3\envs\snp\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: 找不到指定的模組。
原因:pyzmq版本不匹配問題,需要解除安裝舊的,在虛擬環境安裝新的版本
解決方法:在虛擬環境下pip uninstall pyzmq,然後pip install pyzmq
解除安裝重灌pyzmq
成功:虛擬環境新增成功。(雖然還是同樣的版本)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69989885/viewspace-2745161/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 將onda虛擬環境新增到Jupyter Notebook
- Jupyter notebook 新增虛擬環境
- (全)Python 的虛擬環境構建和jupyter notebook 中虛擬環境切換Python
- 將新建的虛擬環境匯入jupyter notebook中使用
- jupyter notebook中 切換不同的Python環境Python
- jupyter notebook外掛環境配置
- jupyter notebook如何選擇conda環境
- Python環境的安裝(Anaconda+Jupyter notebook+Pycharm)PythonPyCharm
- Python虛擬環境Python
- Conda虛擬環境管理與Jupyter kernel管理
- python虛擬環境搭建Python
- Python - 虛擬環境 venvPython
- 建立python虛擬環境Python
- Python搭建虛擬環境Python
- 建立 Python 虛擬環境Python
- 虛擬環境的jupter notebook 版本升級問題
- 基於Ubuntu+Python+Tensorflow+Jupyter notebook搭建深度學習環境UbuntuPython深度學習
- Python虛擬環境介紹Python
- 【PYTHON3】虛擬環境Python
- python virtualenv虛擬環境搭建Python
- 建立Python虛擬環境——下Python
- python的虛擬環境virtualenvPython
- python下多環境開發(虛擬環境)Python
- 關於Python3中venv虛擬環境Python
- Jupyter notebook/nteract/Atom中配置scala互動式程式設計環境程式設計
- 深度學習環境安裝-conda-torch-Jupyter Notebook深度學習
- Python 外掛虛擬環境支援Python
- Django(2)python虛擬環境virtualenvwrapperDjangoPythonAPP
- Python 版本及虛擬環境管理Python
- python多版本與虛擬環境Python
- Python虛擬環境指南2019版Python
- 虛擬環境
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- Jupyter Notebook 中同時使用 Python 和 RPython
- MacOS 系統中如何設定 Python 虛擬環境MacPython
- python中虛擬環境virtualenvwrapper的安裝和使用PythonAPP
- 如何基於Jupyter notebook搭建Spark叢集開發環境Spark開發環境
- Python虛擬環境 flask快速啟動PythonFlask