我有一个在覆盆子圆周率上运行的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.shsudo 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.

推荐答案

答案是,conab以超级用户身份运行应用程序,因此必须使用sudo安装这些包

sudo pip install pandas 

解决了问题. 大喊答题到CoderMike

Python相关问答推荐

OpenCV轮廓.很难找到给定图像的所需轮廓

判断Python操作:如何从字面上得到所有decorator ?

在电影中向西北方向对齐""

如何将相同组的值添加到嵌套的Pandas Maprame的倒数第二个索引级别

如何重新组织我的Pandas DataFrame,使列名成为列值?

每次查询的流通股数量

Python协议不兼容警告

使用pythonminidom过滤XML文件

Groupby并在组内比较单独行上的两个时间戳

跨两个数据帧收集非索引列上的公共组

如何仅使用数据帧操作获得特定的唯一数据帧组合?

如何从NumPy数组中提取主频?

将标量值作为输入并输出矩阵的函数的积分

在POLARS中,如何命名使用GROUP_BY和N_UNIQUE创建的列?

为什么REGISTER_NEXT_STEP_HANDLER不立即调用函数并等待另一条消息

JAX是否保存了JIT编译函数的jaxpr?

真正的Python散布函数

无法调用Python文档对象

将Hangman游戏中的&替换为所有比赛的玩家猜测

Pandas 多列数据帧的重采样和内插