Mac安装timewheel后仍遇ModuleNotFoundError问题求助
问题:导入timewheel模块失败,提示ModuleNotFoundError
尝试使用timewheel-scheduler功能时,执行from timewheel import TimeWheel报错:
ModuleNotFoundError: No module named 'timewheel'
环境信息
- pip版本:
pip 22.1.2 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
- Python版本:
Python 3.7.4
- timewheel包安装信息:
pip show timewheel Name: TimeWheel Version: 0.0.5 Summary: Python implementation of time wheel,Task runer,Cache Home-page: https://www.pkold.com Author: zhenruyan Author-email: baiyangwangzhan@hotmail.com License: WTFPL Location: /opt/homebrew/lib/python3.9/site-packages Requires: Required-by:
补充路径信息
- 当前Python路径:
which python /opt/anaconda3/bin/python
- 系统PATH:
echo $PATH /Users/adrian/.pyenv/bin:/usr/local/opt/python/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin
问题原因
你当前运行代码用的是Anaconda的Python 3.7.4,但执行pip install的是Homebrew配套Python 3.9的pip,导致timewheel被装到了Python 3.9的站点包目录里,Python 3.7自然找不到这个模块。
解决方法
- 方法1:用对应Python版本的pip重新安装
直接调用Anaconda Python 3.7的pip来安装包:
/opt/anaconda3/bin/pip install timewheel timewheel-scheduler
- 方法2:激活Anaconda虚拟环境后安装
如果你用了Anaconda的虚拟环境,先激活目标环境再安装:
conda activate 你的环境名 pip install timewheel timewheel-scheduler
- 方法3:切换到Python 3.9运行代码
不想重新安装的话,直接用Python 3.9来执行你的脚本:
/opt/homebrew/bin/python3.9 你的脚本.py
内容的提问来源于stack exchange,提问作者shark
相关产品推荐
相关产品推荐

