- shutdown after one picture taken - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum  

- shutdown after one picture taken

  • 16 Replies
  • 6154 Views
Re: - shutdown after one picture taken
« Reply #10 on: 28 / April / 2020, 03:02:38 »
Advertisements
You might want to check out this forum thread..  CHDKPTP based Photobooth

I put a bunch of detail in the fifth post.
I tried to use it, but it's not in Python and i got too much error when i wanted to compile and run it.
It was  a quick & dirty program written in generic C.  It was never intended to compile under Python.

Hi, yes i tried to compile and then running it with gcc, but i prefer to continue in Python because i have already the main photobooth functions done :)

*

Offline reyalp

  • ******
  • 14080
Re: - shutdown after one picture taken
« Reply #11 on: 28 / April / 2020, 13:09:20 »
Thanks i succeed to install it, but now i get an error when i try to import it:
i tried
import chdkptp :does'nt work,

I tried to change my python command startup :
python photobooth_control.py by python3 photobooth_control.py still get the error:

File "photobooth_control.py", line 7, in <module>
     import chdkptp_py
ModuleNotFoundError: No module named 'chdkptp'
It should be
Code: [Select]
import chdkptp
not chdkptp_py
Don't forget what the H stands for.

Re: - shutdown after one picture taken
« Reply #12 on: 28 / April / 2020, 13:46:52 »
Thanks i succeed to install it, but now i get an error when i try to import it:
i tried
import chdkptp :does'nt work,

I tried to change my python command startup :
python photobooth_control.py by python3 photobooth_control.py still get the error:

File "photobooth_control.py", line 7, in <module>
     import chdkptp_py
ModuleNotFoundError: No module named 'chdkptp'
It should be
Code: [Select]
import chdkptp
not chdkptp_py

Thanks, yes i still get the error, something is wrong with the module python, like it was not installed but i got the message that it was installed...

*

Offline reyalp

  • ******
  • 14080
Re: - shutdown after one picture taken
« Reply #13 on: 28 / April / 2020, 16:10:38 »
Thanks, yes i still get the error, something is wrong with the module python, like it was not installed but i got the message that it was installed...
This probably means either the module did not install successfully, or the python environment isn't configured to look in the right place. You need to look around your system and figure out what actually happened, and where python is looking for the modules. The python documentation may be helpful
 https://docs.python.org/3/installing/index.html
 https://docs.python.org/3/tutorial/modules.html

If you run python interactively,
Code: [Select]
import sys
sys.path
will show you the python search path

Typically, when you install a module outside of a virtual environment, the files would go in /usr/lib/pythonX.Y if installed by root, or under ~/.local/... if a normal users

If you are using a venv, you should install all the packages with it active, and have it active when you run python

I would also suggest getting the chdkptp module working interactively before trying to integrate it into your photobooth program.
Don't forget what the H stands for.


Re: - shutdown after one picture taken
« Reply #14 on: 29 / April / 2020, 04:35:05 »
Hi,

Thanks! I checked and i got:

Code: [Select]
pi@raspberrypi:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/pi/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']
>>> quit()

but I saw that the chdkptp.py was installed in ~/.local/lib/python2.7/site-packages/chdkptp

So i installed again the chdkptp.py with "sudo" to make it not local:

Code: [Select]
pi@raspberrypi:/ $ sudo pip install https://github.com/5up3rD4n1/chdkptp.py/releases/download/v0.1.4/chdkptp.py-0.1.4.tar.gz
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting https://github.com/5up3rD4n1/chdkptp.py/releases/download/v0.1.4/chdkptp.py-0.1.4.tar.gz
  Downloading https://github.com/5up3rD4n1/chdkptp.py/releases/download/v0.1.4/chdkptp.py-0.1.4.tar.gz (1.5MB)
    100% |████████████████████████████████| 1.5MB 80kB/s
Requirement already satisfied: lupa>=1.1 in /usr/local/lib/python2.7/dist-packages (from chdkptp.py==0.1.4) (1.9)
Building wheels for collected packages: chdkptp.py
  Running setup.py bdist_wheel for chdkptp.py ... done
  Stored in directory: /root/.cache/pip/wheels/d9/15/26/318c64e58d643efe9c575cecca308be93b2d2df5aa19327caa
Successfully built chdkptp.py
Installing collected packages: chdkptp.py
Successfully installed chdkptp.py-0.1.4

Then, i tried and i got a different error :

Code: [Select]
pi@raspberrypi:/ $ sudo python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import chdkptp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "chdkptp.py", line 1
   
    ^
SyntaxError: I/O error while reading
>>>
« Last Edit: 29 / April / 2020, 04:50:28 by bourbourg »

*

Offline reyalp

  • ******
  • 14080
Re: - shutdown after one picture taken
« Reply #15 on: 29 / April / 2020, 13:57:33 »
The error says "I/O error", which sounds like some file is missing, or there's a permission problem (but root shouldn't have those) or there was a real I/O error. Again, look at the files and try to figure out what's actually going on.

FWIW, https://github.com/5up3rD4n1/chdkptp.py  says
"NOTE: if you installed the package and you are inside the repo dir and try to import chdkptp, it will probably throw an error because python is loading the local dir module not the installed one."
So if you had some leftover files sitting around from previous attempts, that might cause a problem.

It also says:
"Before installation make sure you are running python3.6"

I don't know if this is related to your problem, but you can use python3 to run python 3.x, instead of the 2.x you are using now. They use separate packages, so you'd need to install with pip3 rather than pip. Or use a venv.
Don't forget what the H stands for.

Re: - shutdown after one picture taken
« Reply #16 on: 01 / May / 2020, 12:38:08 »
The error says "I/O error", which sounds like some file is missing, or there's a permission problem (but root shouldn't have those) or there was a real I/O error. Again, look at the files and try to figure out what's actually going on.

FWIW, https://github.com/5up3rD4n1/chdkptp.py  says
"NOTE: if you installed the package and you are inside the repo dir and try to import chdkptp, it will probably throw an error because python is loading the local dir module not the installed one."
So if you had some leftover files sitting around from previous attempts, that might cause a problem.

It also says:
"Before installation make sure you are running python3.6"
I don't know if this is related to your problem, but you can use python3 to run python 3.x, instead of the 2.x you are using now. They use separate packages, so you'd need to install with pip3 rather than pip. Or use a venv.
Hi,
Thanks !
I tried a lot of different things on a new raspberry system, and i succeed to make it work with the post of jbaiter on this page :
https://github.com/DIYBookScanner/spreads/issues/229

So, i did this actions on my raspberry (i put back my photomaton python system on my sd card from a backup before the first installation attempt of chdkptp.py):

Code: [Select]
sudo apt-get update
sudo apt-get install liblua5.2-dev
sudo apt-get install build-essential libusb-dev libreadline-dev
sudo apt autoremove
pip install lupa --install-option='--no-luajit'
sudo pip install https://github.com/5up3rD4n1/chdkptp.py/releases/download/v0.1.4/chdkptp.py-0.1.4.tar.gz
At this point, it doesn't work, so i just added:
Code: [Select]
pip uninstall chdkptp.py
pip install --no-cache-dir --verbose chdkptp.py

At this point, python and then import chdkptp works!
I added this to make my canon device able to communicate with python :

Code: [Select]
sudo chmod 664 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
sudo chmod -x /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
sudo chmod -x /usr/lib/gvfs/gvfsd-gphoto2

At this point, i am able to do:
Code: [Select]
pi@raspberrypi:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import chdkptp
>>> chdkptp.list_devices()
[DeviceInfo(model_name='Canon PowerShot A2200', bus_num='001', device_num='012', vendor_id=1193, product_id=12842, serial_num='12A16CC3FA404E0586B1F13D55679506', chdk_api=(2, 8))]
>>> dev = chdkptp.ChdkDevice(chdkptp.list_devices()[0])
>>> dev.switch_mode('record')
>>>

So now, i have to continue to test how to use chdkptp.py, like how to shoot a picture, and then i will try to integrate it in my photobooth :)

 

Related Topics