我有一个在覆盆子圆周率上运行的Python 脚本.
我定义了一个launcher.sh
文件,并try 使用sh launcher.sh
来运行程序
档案
cd /home/pi/Documents
PYTHONPATH=/home/pi/.local/lib/python3.10/site-packages
python3 /home/pi/Documents/myfile.py
我试了chmod launcher.sh
和sudo chmod 775 launcher.sh
但当我在 bootstrap 时启动启动程序时,我在cronlog中记录了一个错误:
将Pandas 作为PD模块导入NotFoundError无模块命名Pandas
我在Raspberry 3.9和3.10上确实有两个版本的Python(遗憾的是不是在环境中).
pip list
给我:pandas 1.4.3
python --version
给我Python 3.10.0
python3 --version
也给我Python 3.10.0
在/home/pi/.local/lib/
中,我有一个python3.10和python3.9文件夹.两者在站点包中都有一个Pandas文件夹.我刚才看到,pyhton3.9文件夹也有Pandas-1.4.3Dist.info文件夹(Python3.10没有).
Cronab行如下所示:
@reboot sh /home/pi/launcher.sh >/home/pi/logs/cronlog 2>&1
我不明白...
是不是Python3.9文件夹以某种方式截取...但我确实设置了PythonPath,try 以sh launcher.sh
运行确实有效,所以我想知道出了什么问题.不知何故,我猜是用错了Python .
谢谢你的帮忙
编辑:
我给/home/pi/.local/lib/python3.9
起了个新名字,go 掉了边包...但没有变化
编辑:我try 用以下命令更改了python3.10和3.9的优先级
sudo update-alternatives --install $(which python) python $(readlink -f $(which python3.10)) 3
sudo update-alternatives --install $(which python) python $(readlink -f $(which python3.9)) 2
没有运气的话
编辑:添加了python3--版本建议
编辑:try 为python3.9安装Pandas时出现错误消息
对于pyhton3.9 -m pip install pandas
,请参见下面的输出.
.almost FINAL EDIT:......
我按照建议的here卸载(清除)了python,然后通过this great link重新安装了python3.10 不幸的是,在卸载时,我猜也卸载了python2.7,导致系统在启动时完全失败.->;在夜里3点失go 所有希望;-)现在重新开始重新设置SD-IMAGE.
我会更新最后一次,当我运行它与 fresh 的图像
Thank you all so much for your interest and participation. I love this community个
.
> ERROR: Exception: Traceback (most recent call last): File
> "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py",
> line 223, in _main
> status = self.run(options, args) File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py",
> line 180, in wrapper
> return func(self, options, args) File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py",
> line 297, in run
> session = self.get_default_session(options) File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py",
> line 78, in get_default_session
> self._session = self.enter_context(self._build_session(options)) File
> "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py",
> line 88, in _build_session
> session = PipSession( File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py",
> line 248, in __init__
> self.headers["User-Agent"] = user_agent() File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py",
> line 131, in user_agent
> zip(["name", "version", "id"], distro.linux_distribution()), File
> "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 125, in linux_distribution
> return _distro.linux_distribution(full_distribution_name) File "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 681, in linux_distribution
> self.version(), File "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 741, in version
> self.lsb_release_attr('release'), File "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 903, in lsb_release_attr
> return self._lsb_release_info.get(attribute, '') File "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 556, in __get__
> ret = obj.__dict__[self._fname] = self._f(obj) File "/usr/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl/distro.py",
> line 1014, in _lsb_release_info
> stdout = subprocess.check_output(cmd, stderr=devnull) File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
> return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.9/subprocess.py", line 528, in run
> raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '('lsb_release', '-a')'
> returned non-zero exit status 1.