目标。
我想建立一个小型的气象站使用树莓Pi 3 B。为了测量温度和湿度,我使用Adafruit DHT22传感器。有一个Python库来读取传感器。
https://pypi.org/project/Adafruit-DHT/
测量完成后,测量数据应发送到服务器。
我所做的。
这个Adafruit_DHT库很挑剔。对于开发,我有以下设置:
git clone ...来获取代码。pipenv是一种推荐的工作流程,所以我尝试在我的笔记本上编写代码,并使用虚拟函数对其进行测试。这不起作用,因为在调用pipenv install Adafruit_DHT时出现了一个错误,因为Adafruit_DHT只在Pi或Beaglebone上工作。ssh连接到Pi和git clone ...的所有内容。pipenv install成功了。pipenv run python measurements.py也起作用了。pipenv run /home/pi/.../main.py,甚至可以使用超级用户权限。遇到问题了。
由于pipenv一直试图创建一个新的虚拟环境,所以它无法工作。我没有找到像yarn --cwd那样的思维方式,就像在在另一条道路上运行纱线里一样。
然后我试了一下pipenv install --system
pipenv install --system
Installing dependencies from Pipfile.lock (dcc369)…
An error occurred while installing adafruit-dht==1.4.0 --hash=sha256:e927f2232eff5335cb9d8a2cca6dcad4625e61f205b12e31ef04198ea6dec830! Will try again.
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 8/8 — 00:00:16
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]: File "/home/pi/.local/lib/python3.7/site-packages/pipenv/core.py", line 1874, in do_install
[pipenv.exceptions.InstallError]: keep_outdated=keep_outdated
[pipenv.exceptions.InstallError]: File "/home/pi/.local/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]: File "/home/pi/.local/lib/python3.7/site-packages/pipenv/core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]: retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]: File "/home/pi/.local/lib/python3.7/site-packages/pipenv/core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]: _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]: File "/home/pi/.local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple', 'Collecting adafruit-dht==1.4.0 (from -r /tmp/pipenv-m9p05m29-requirements/pipenv-uuyle1le-requirement.txt (line 1))', ' Using cached https://www.piwheels.org/simple/adafruit-dht/Adafruit_DHT-1.4.0-cp37-cp37m-linux_armv7l.whl']
[pipenv.exceptions.InstallError]: ['THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.', ' adafruit-dht==1.4.0 from https://www.piwheels.org/simple/adafruit-dht/Adafruit_DHT-1.4.0-cp37-cp37m-linux_armv7l.whl#sha256=3a47d226e77186f89bf167a6568d9ae2cab119333c4b3f5a8ec460f9695a832c (from -r /tmp/pipenv-m9p05m29-requirements/pipenv-uuyle1le-requirement.txt (line 1)):', ' Expected sha256 e927f2232eff5335cb9d8a2cca6dcad4625e61f205b12e31ef04198ea6dec830', ' Got 3a47d226e77186f89bf167a6568d9ae2cab119333c4b3f5a8ec460f9695a832c']
ERROR: ERROR: Package installation failed...一些哈希是如何改变的。怎么会发生这种事?(顺便说一句,我在pipenv install前一分钟运行了pipenv install --system)。
问题。
pip或pipenv的情况下工作。尽管如此,我还是喜欢太极拳。例如,在C++中,只有一个可执行文件可以编译->。pyInstaller冻结程序怎么样?如何同时处理pipenv和pyInstaller。我写这篇文章,因为我已经遇到了更简单的工作流,如Javascript + nodeJs +纱线。
我很感谢你的帮助。
发布于 2020-04-10 10:55:21
关于问题1,在pipenv's Github:crontabs中推荐的使用方法?·问题#1369上讨论了几个观点。
激活正确env的建议选项是在使用pipenv运行之前先将cd放入目录,如下所示
cd /home/pi/.../ && pipenv run main.py
其他选项是激活不带pipenv的虚拟env。
source /path/to/virtualenv/activate && python /home/pi/.../main.py
或者直接指向虚拟环境中的Python。
#!/bin/sh
VENV_PYTHON="/path/to/project-hAsHpTH/bin/python"
PROJECT="/path/to/some/project"
SCRIPT="script.py"
cd "${PROJECT}" && "${VENV_PYTHON}" "${SCRIPT}"https://stackoverflow.com/questions/57231721
复制相似问题