將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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Jupyter notebook 新增虛擬環境
- (全)Python 的虛擬環境構建和jupyter notebook 中虛擬環境切換Python
- jupyter notebook中 切換不同的Python環境Python
- jupyter notebook外掛環境配置
- Python開發環境—— jupyter Notebook 安裝使用Python開發環境
- Python虛擬環境Python
- 虛擬環境的jupter notebook 版本升級問題
- 建立python虛擬環境Python
- Python搭建虛擬環境Python
- Python - 虛擬環境 venvPython
- 建立 Python 虛擬環境Python
- 使用Python虛擬環境Python
- python虛擬環境--virtualenvPython
- python 虛擬環境搭建Python
- Ubuntu python虛擬環境UbuntuPython
- python虛擬環境搭建Python
- Python環境的安裝(Anaconda+Jupyter notebook+Pycharm)PythonPyCharm
- 建立Python虛擬環境——下Python
- python virtualenv虛擬環境搭建Python
- python的虛擬環境virtualenvPython
- Python 虛擬環境全知道Python
- 【PYTHON3】虛擬環境Python
- Python虛擬環境介紹Python
- python下多環境開發(虛擬環境)Python
- 關於Python3中venv虛擬環境Python
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- 基於Ubuntu+Python+Tensorflow+Jupyter notebook搭建深度學習環境UbuntuPython深度學習
- python多版本與虛擬環境Python
- Python 外掛虛擬環境支援Python
- python虛擬開發環境搭建Python開發環境
- python 虛擬環境 virtualenv virtualenvwrapperPythonAPP
- windows安裝Python虛擬環境WindowsPython
- Python3虛擬環境--venvPython
- MacOS 系統中如何設定 Python 虛擬環境MacPython
- 虛擬環境搭建
- Pipenv虛擬環境
- Sublime Python3 虛擬環境配置Python
- Win 10 安裝 Python 虛擬環境Python