简体   繁体   English

Raspberry Pi BeautifulSoup 库不起作用

[英]Raspberry Pi BeautifulSoup library not working

We are working on a school project where we are trying to use a Raspberry Pi to build a Is-the-bathroom-free monitor.我们正在开展一个学校项目,我们正在尝试使用 Raspberry Pi 构建一个 Is-the-the-bathroom-free 监视器。

When we try to run the python script "tolett.py" it says that it can't find the module named "bs4".当我们尝试运行 python 脚本“tolett.py”时,它说它找不到名为“bs4”的模块。 We have tried all kinds of combinations, not just bs4.我们尝试了各种组合,不仅仅是bs4。 What the python script is basically supposed to do is update the status.html file and upload it to dropbox where we will later get the information about whether or not the bathroom is free. python 脚本基本上应该做的是更新 status.html 文件并将其上传到 dropbox,我们稍后将在那里获取有关浴室是否免费的信息。

BUT when we run it as non root it goes through, but then we get permission denied '/home/pi/status.html'.但是,当我们以非 root 用户身份运行它时,它会通过,但随后我们得到了拒绝“/home/pi/status.html”的许可。 So we're screwed both ways.所以我们两方面都搞砸了。 We're stuck and would love some help.我们被困住了,希望得到一些帮助。

代码和终端消息的图片

I see two probable causes:我看到两个可能的原因:

  1. The default pip is not the Python3 version, but rather Python2.默认的pip不是 Python3 版本,而是 Python2。 You can check with the command: pip --version .您可以使用以下命令进行检查: pip --version In this case you have installed beautifulSoup module for Python2 not Python3.在这种情况下,您已经为 Python2 而不是 Python3 安装了 beautifulSoup 模块。 On my Ubuntu system I have an alternative pip3 , which is for Python3.在我的 Ubuntu 系统上,我有一个替代pip3 ,它用于 Python3。 You can check the existence of pip3 on your raspberry pi with the command: which pip3 .您可以使用以下命令检查树莓pip3是否存在pip3which pip3
  2. You have indeed installed beautifulSoup for Python3, but the path Python3 uses does not contain the directory in which the beautifulSoup module resides.您确实为Python3安装了beautifulSoup,但是Python3使用的路径不包含beautifulSoup模块所在的目录。 You can check the install location of a module with pip show module_name .您可以使用pip show module_name检查模块的安装位置。 You can check the path of your Python3 interpreter with a Python3 script:您可以使用 Python3 脚本检查 Python3 解释器的路径:

     import sys print(sys.path)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM