我的python项目由许多模块组成,每个模块之间都有import语句。在我的Eclipse PyDev环境中,这些import语句工作得很好,但是当将其移植到我的Raspberry时,运行时环境无法加载依赖模块
我已经配置了PYTHONPATH,以便我的项目的根目录(/home/pi/Desktop/Projects/Catatumbo)列在sys.path
:
['/var/www/upload/Projects/Catatumbo',
'/home/pi/Desktop/Projects/Catatumbo',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-arm-linux-gnueabihf',
'/usr/lib/python3.5/lib-dynload',
'/home/pi/.local/lib/python3.5/site-packages',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages']
项目结构如下:
-core
--adafruit
---forecast (That's where the utility class resides)
-forecast
--adafruit (That's where the script resides)
通过以下方式从项目根目录启动脚本:
sudo python3 forecast/adafruit/adafruit_forecast.py
仍然会导致以下错误:
File "forecast/adafruit/adafruit_forecast.py", line 35, in <module>
from core.adafruit.forecast.forecast_colors import ForecastNeoPixelColors
ImportError: No module named 'core'
谢谢你的帮助
卡娅的话让我读到了这篇有用的article:
这样做,您将遇到'Parent module '' not loaded, cannot perform relative import'问题。将脚本作为模块运行将最终解决问题:
相关问题 更多 >
编程相关推荐