There is a file with a “configuration” from which the variables are taken
File – __ Main __. PY
import sys
Import Getopt.
Import OS.
Import Picamera.
From Raspm Import Raspm
Camera = none
CAMLOCK = LOCK ()
Usage = '' '
Usage% s [options] Command
Commands:
RUN - START RPM AS RASPBERRY PI Manager (Default)
HTTP Server - Start Only Http Server
Configuration:
- Configuration Specified on the Command Line
- /etc/rpm.conf.
- ./etc/rpm.conf.
'' '
Def usage (Retval = 0):
Print (Usage% sys.argv [0])
SYS.EXIT (Retval)
IF __name__ == "__main__":
CFG = '/etc/rpm.conf' if os.path.isfile ('/ etc / rpm.conf') else './etc/rpm.conf'
Try:
App.Run (Host = '0.0.0.0, port =' 8080 ')
Opts, args = getopt.getopt (sys.argv [1:], 'HC:' ['Help', 'Config ='])
Finally:
#After Work is Finished SHUT OFF THE CAMERA
With CamLock:
IF Camera:
Camera.Close ()
File –
raspm.py
....
Def Update_Configuration (CFGfile):
From Configobj Import Configobj
from raspm.config import cfgspec
From Validate Import Validator
CFG = Configobj (CFGFile, ConfigSpec = CFGSPEC)
Validator = Validator ()
CFG.Validate (Validator)
Globals () ['Config'] = CFG
Return CFG.
# SET UP Configuration
Config = Update_configuration ('/ etc / rpm.conf')
...
Next Config file config.py
# - * - Coding: UTF-8 - * -
'' '
Default Configuration.
'' '
__Cfg = '' '
......
'' '
CFGSpec = __cfg.split ('\ n')
and last rpm.conf
When starting __ Main __. PY
I get the following:
traceback (most recent call last):
File "__main__.py", Line 19, In & Lt; Module & GT;
From Raspm Import Raspm
File "/home/pi/python-rpi-camera-controll/raspm/raspm.py", line 73, in & lt; module & gt;
Config = update_configuration ('./ etc / rpm.conf')
File "/home/pi/python-rpi-camera-controll/raspm/raspm.py", Line 64, In Update_Configuration
from rpm.config import cfgspec
Importerror: No Module Named RPM.config
Files in Folders:
python /
- ETC /
- - rpm.conf.
- RASPM /
- - __main__.py.
- - Config.py.
- - raspm.py.
So I do not understand what the problem is
Answer 1, Authority 100%
file "/home/pi/python-rpi-camera-controll/raspm/raspm.py", line 64 , In Update_configuration
from rpm.config import cfgspec
Importerror: No Module Named RPM.config
in the raspm.py file (64 line) must be:
from raspm.config import cfgspec
In the Raspm /
folder>Put (empty) file __ init __. PY
.
├── F1
│ & nbsp; & nbsp; ├── __init__.py.
│ & nbsp; & nbsp; ├── PF1.PY.
├── F2.
│ & nbsp; & nbsp; ├── __init__.py.
│ & nbsp; & nbsp; ├── Pf2.py.
└── Main.py.
Main.py:
from f1.pf1 import fun1
FUN1 ()
pf1.py:
from f2.pf2 import fun2
DEF FUN1 ():
Print "I Am Fun1"
FUN2 ()
pf2.py:
def fun2 ():
Print "I Am Fun2"
Perform:
$ python main.py
I Am Fun1
I Am Fun2.
Somehow imports from subfolders in Python.
Well, I agree, all imports – at the beginning of the file.