mac写了一个python脚本,本地执行可以正常运行。但是crontab定时任务总会报错,
提示无法从lxml导入etree。但是我在pycharm中导入lxml和etree都是正常的,
请教各位是什么问题?定时任务之前运行也是正常的,但有一次弹出一个提示,让我安装一个什么插件才可以运行python脚本,安装以后就开始不正常了,一开始提示我找不到tushare这个包,我在py文件里加了sys.append路径,加好之后可以导入tushare,又提示我无法从lxml导入etree。无语
Traceback (most recent call last):
File "/Users/yifang/PycharmProjects/financial_report/crontab_task.py", line 4, in <module>
import hk_hold, daily_basic, pandas as pd
File "/Users/yifang/PycharmProjects/financial_report/hk_hold.py", line 1, in <module>
import tushare as ts
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tushare/__init__.py", line 11, in <module>
from tushare.stock.trading import (get_hist_data, get_tick_data,
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tushare/stock/trading.py", line 13, in <module>
import lxml.html
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/lxml/html/__init__.py", line 49, in <module>
from .. import etree
ImportError: cannot import name 'etree' from 'lxml' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/lxml/__init__.py)