0
我有一個python jupyter
筆記本,我試圖在命令行上執行。下面是一個命令:運行juptyer筆記本時如何修復導入錯誤?
jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=60 --output out_file test.ipynb
這裏是這款筆記本(test.ipynb
)
{"cells":[{"metadata":{"deletable":true,"editable":true},"cell_type":"markdown","source":["# Morphology analysis with neurom\n","\n","You can find the full documentation of neurom on http://neurom.readthedocs.io/en/latest/index.html ."]},{"metadata":{"collapsed":false,"deletable":true,"editable":true,"trusted":false},"cell_type":"code","source":["%matplotlib inline\n","from copy import deepcopy\n","\n","from IPython.display import display, HTML\n","import urllib, zipfile, os\n","\n","try:\n"," import neurom\n"," from neurom import viewer, stats\n","except ImportError:\n"," !pip2 install neurom\n"," import neurom\n"," from neurom import viewer, stats"],"execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python2","display_name":"Python 2","language":"python"},"language_info":{"version":"2.7.6","mimetype":"text/x-python","file_extension":".py","codemirror_mode":{"version":2,"name":"ipython"},"nbconvert_exporter":"python","name":"python","pygments_lexer":"ipython2"}},"nbformat":4,"nbformat_minor":2}
對應於下面的代碼的測試版本:
get_ipython().magic(u'matplotlib inline')
from copy import deepcopy
from IPython.display import display, HTML
import urllib, zipfile, os
try:
import neurom
from neurom import viewer, stats
except ImportError:
get_ipython().system(u'pip2 install neurom')
import neurom
from neurom import viewer, stats
運行這段代碼與上面的命令,我得到以下錯誤
ImportError: No module named neurom
儘管此模塊安裝在當前設置中。那麼,python爲什麼不拿起這個模塊呢?