虽然我通过pip和pip3安装了skpy,但当我在终端上命令jupyter execute
时,错误发生了。Python 3.9.13 pip 22.2.2 from /Users/username/opt/anaconda3/lib/python3.9/site-packages/pip (python 3.9)
证明我安装了skpy
第一个
执行命令
(base) username@MacBook-Pro-3 test-directory % /Library/Frameworks/Python.framework/Versions/3.10/bin/jupyter execute /Users/username/Desktop/job/test-directory/createNewShiftTab.ipynb
运行上述命令后出错
[NbClientApp] Executing /Users/username/Desktop/job/test-directory/createNewShiftTab.ipynb
[NbClientApp] Executing notebook with kernel: python3
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jupyter-execute", line 8, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jupyter_core/application.py", line 276, in launch_instance
return super().launch_instance(argv=argv, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/traitlets/config/application.py", line 981, in launch_instance
app.initialize(argv)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/traitlets/config/application.py", line 110, in inner
return method(app, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/cli.py", line 113, in initialize
[self.run_notebook(path) for path in self.notebooks]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/cli.py", line 113, in <listcomp>
[self.run_notebook(path) for path in self.notebooks]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/cli.py", line 154, in run_notebook
client.execute()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/util.py", line 85, in wrapped
return just_run(coro(*args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/util.py", line 60, in just_run
return loop.run_until_complete(coro)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/client.py", line 701, in async_execute
await self.async_execute_cell(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/client.py", line 1019, in async_execute_cell
await self._check_raise_for_error(cell, cell_index, exec_reply)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbclient/client.py", line 913, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In [1], line 9
6 from oauth2client.service_account import ServiceAccountCredentials
7 # print(sys.path) importしたモジュールの探索先ディレクトリを一覧表示
8 #Skype操作
----> 9 from skpy import Skype
ModuleNotFoundError: No module named 'skpy'
ModuleNotFoundError: No module named 'skpy'
但是当我直接在JupyterLab浏览器上执行时,并没有出现下面的情况,所以我感到困惑。enter image description here
这是sys.path的输出
['/Users/username/Desktop/job/automation', '/Users/username/opt/anaconda3/lib/python39.zip', '/Users/username/opt/anaconda3/lib/python3.9', '/Users/username/opt/anaconda3/lib/python3.9/lib-dynload', '', '/Users/username/opt/anaconda3/lib/python3.9/site-packages', '/Users/username/opt/anaconda3/lib/python3.9/site-packages/aeosa', '/Users/username/opt/anaconda3/lib/python3.9/site-packages/IPython/extensions', '/Users/username/.ipython']
- 运行
print(sys.path)
,然后确认模块位于python搜索以使用模块的目录中 - 重新启动mac、终端、jupyter
- 将文本从“skpy”修复为“SkPy”
但都不管用
2条答案
按热度按时间kyvafyod1#
作为一个发挥过Rubizzo的回答:
一个非常简单的修复方法是使用与您的juypter笔记本相同的Python版本进行安装。
应该这样做。
进一步说明:您似乎安装了Python的多个版本。如果您运行
您将看到您所拥有的所有Python 3.xx.xx安装。
但是你可以选择任何一个python版本,使用它们的完整路径来运行一个文件或者使用pip。
omhiaaxx2#
你有两个不同版本的python3。你安装了python3.9的包,但Jupyter使用python3.10。或者你强制Jupyter使用python3.9,或者你也安装了python3.10的包。