英文:
What environment is my jupyter notebook runninng on when I launch it from my terminal?
问题
当我启动jupyter notebook
时,我正在使用一个conda环境,我的环境中安装了Python 3.8。
然而,当我启动笔记本并尝试导入包时,我遇到了(请注意最后一行):
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-2b...8b8> in <module>
----> 1 from blah import reference
~/work/blah/blah/__init__.py in <module>
66 from ._internals.api import configure as _configure
67 from ._internals.api.utils.warnings import PatchWarning as _PatchWarning
68
~/work/blah/blah/_internals/api/configure.py in <module>
12 from blah._internals.rest import user
13 from blah._internals.api.utils.authentication import get_token
14 from blah._internals.api.utils.exceptions import BmllError
~/work/blah/blah/_internals/rest.py in <module>
15 from typing import Dict, Optional, TypedDict
16
ImportError: cannot import name 'TypedDict' from 'typing' (/home/pchong/anaconda3/lib/python3.7/typing.py)
从最后一行可以清楚地看出,它正在使用Python 3.7。
英文:
I am using a conda environment when I launch jupyter notebook
, and my environment has Python 3.8 installed.
However, when I launch the notebook and try to import packages, I get (note the LAST LINE):
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-2b...8b8> in <module>
----> 1 from blah import reference
~/work/blah/blah/__init__.py in <module>
64
65 # Private methods for use here
---> 66 from ._internals.api import configure as _configure
67 from ._internals.api.utils.warnings import PatchWarning as _PatchWarning
68
~/work/blah/blah/_internals/api/configure.py in <module>
10 from typeguard import typechecked
11
---> 12 from blah._internals.rest import user
13 from blah._internals.api.utils.authentication import get_token
14 from blah._internals.api.utils.exceptions import BmllError
~/work/blah/blah/_internals/rest.py in <module>
13 from functools import wraps
14 from http import HTTPStatus
---> 15 from typing import Dict, Optional, TypedDict
16
17 from requests import request
ImportError: cannot import name 'TypedDict' from 'typing' (/home/pchong/anaconda3/lib/python3.7/typing.py)
From the last line it is clear that it is using python3.7??
答案1
得分: 1
如果您能看到导入错误路径,它显示为Python 3.7。因此,默认情况下,Jupyter笔记本在您使用conda安装的Python环境中运行。您可以通过创建一个虚拟的conda环境来轻松解决这个问题,使用以下命令:
conda create -n yourenvname python=3.8
然后在该终端中启动Jupyter笔记本。
提示:VS Code可以非常顺利地执行这个操作。
英文:
If you can see the import error path it says python 3.7, So by default the jupyter notebook runs on the python environment you installed using conda, you can easily solve this issue by creating a virtual conda environment using
conda create -n yourenvname python=3.8
and then launch jupyter notebook from that terminal.
Tip: VS code does this very smoothly
答案2
得分: 0
你可以使用所需版本来运行 Jupyter Notebook:
<path_to_python> -m jupyter notebook
英文:
You can run jupyter notebook using desired version by:
<path_to_python> -m jupyter notebook
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论