gpt4 book ai didi

python - 导入错误 : No module named schedule

转载 作者:行者123 更新时间:2023-12-05 05:36:08 27 4
gpt4 key购买 nike

我在 osx 系统上制作了一个计划程序,我试图在后台运行它,我读到一个不同的问题,它说这应该通过使用这个命令在终端中工作,我也试过以 root 身份下载模块,没有任何改变:

python /Users/teddy/Desktop/herumblödeln/main.py &

但是终端返回错误:

teddy@Teddys-MBP ~ % Traceback (most recent call last):
File "/Users/teddy/Desktop/herumblödeln/main.py", line 1, in <module>
import schedule
ImportError: No module named schedule

为什么会这样?

我的代码是这样的:

import time
import schedule
import docx
from pync import Notifier
import tkinter as tk
from tkinter import simpledialog

运行 pip freeze 返回

teddy@Teddys-MBP ~ % pip freeze
asteval==0.9.27
cycler==0.11.0
et-xmlfile==1.1.0
fonttools==4.28.3
future==0.18.2
imageio==2.19.5
kiwisolver==1.3.2
lmfit==1.0.3
lxml==4.9.1
matplotlib==3.5.1
mpmath==1.2.1
networkx==2.8.5
numpy==1.21.4
openpyxl==3.0.10
packaging==21.3
pandas==1.4.3
Pillow==8.4.0
plyer==2.0.0
pync==2.0.3
pyparsing==3.0.6
python-dateutil==2.8.2
python-docx==0.8.11
pytz==2022.1
PyWavelets==1.3.0
schedule==1.1.0
scikit-image==0.19.3
scipy==1.8.1
six==1.16.0
sympy==1.10.1
tifffile==2022.5.4
uncertainties==3.1.7
XlsxWriter==3.0.3

pip -V 和 python -V 的结果

teddy@Teddys-MBP ~ % pip -V
pip 22.2.2 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip (python 3.10)
teddy@Teddys-MBP ~ % python -V
Python 2.7.18

最佳答案

在你的终端运行 pip install schedule,你的输出信息应该是 Requirement already satisfy 因为你已经安装了它,只是你在不同的 venv.

现在,在Requirement already satisfied 消息之前,您将找到一个路径复制那个路径

现在转到您的 main.py,因为这是发现错误的地方。在import schedule 之前,您应该import sys。例如:

import sys

sys.path.append("/past/the/path/you/copied/here")

import schedule

关于python - 导入错误 : No module named schedule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73346311/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com