tolstoyevsky / pieman

A script for creating custom OS images for single-board computers
GNU General Public License v3.0
215 stars 32 forks source link

Installing python packages while building custom Raspberry pi OS #280

Open Beebeejohn opened 3 years ago

Beebeejohn commented 3 years ago

How to install python packages like Adafruit.ads1x15.ads1115,busio,time,json,logging while building raspberry pi Os using piemann

eugulixes commented 3 years ago
  1. You have to add a post-install hook to devices/rpi-2-b/raspbian-buster-armhf/post-install. The hook might look like (I named it run-pip3.sh)
    #/bin/sh
    pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280
  2. Run sudo env INCLUDES=python3-pip ./pieman.sh
Beebeejohn commented 3 years ago

Actually where this run-pip3.sh is there? Can you tell me the path. I searched it . But I could not get it. And also this command where should I mention pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280. Should I mention this line in pieman.sh script

eugulixes commented 3 years ago
  1. Go to devices/rpi-2-b/raspbian-buster-armhf/
  2. Create a directory named post-install and go to the directory
  3. Create a file named run-pip3.sh with the following contents
    #/bin/sh
    pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280
  4. Run sudo env INCLUDES=python3-pip ./pieman.sh

And also this command where should I mention pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280. Should I mention this line in pieman.sh script

No, you don't have to touch pieman.sh.

Beebeejohn commented 3 years ago

Ok. Thank you so much for the replies. If I want to install multiple python packages like adafruit-blinka, adafruit-io, In the pip3.sh file, should I mention the contents as follows: pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280 pip3 install Adafruit-Blinka pip3 install adafruit-io Can you tell me

eugulixes commented 3 years ago

yeah, you can either use multiple lines like that or put it in one line as pip3 install adafruit-circuitpython-ads1x15 adafruit-circuitpython-bme280 Adafruit-Blinka adafruit-io

Beebeejohn commented 3 years ago

ya ok thank you

Beebeejohn commented 3 years ago

I tried with the above command as mentioned. But adafruit-blinka and ads1115 packages are not getting installed in python. It is showing no module found error. Can you tell me the exact command for installing supervisor, ssh and also python packages like adafruit-blinka, etc., in a single command itself . Because I need supervisor, ssh also along with python packages. I tried with this command sudo env INCLUDES=ssh,supervisor,python3-pip ./pieman.sh. But it is showing no module found error for adafruit and supervisor is installed properly without any issues Can you tell me the command please? Whether do I need to use env also or not needed?

Beebeejohn commented 3 years ago

Can anyone pls answer my above question?

eugulixes commented 3 years ago

Fortunately or unfortunately I'm not able to read people's mind, so 1) explain what you did step by step, 2) attach some tracebacks or anything else what could help me or anyone else to help you.

Can you tell me the exact command for installing supervisor, ssh and also python packages like adafruit-blinka, etc., in a single command itself

There is no a single command because you have to install Python packages via pip3 and hooks as I mentioned above.

Whether do I need to use env also or not needed?

It depends your task.

Beebeejohn commented 3 years ago

The steps I followed are below:

  1. I entered Wi-Fi SSID and password details in pieman.sh script and enabled wireless is equal to true then made DEVICE="rpi-zero-w"
  2. I created new folder named post-install under devices/rpi-zero-w. (Because the raspberry pi, I am using for this experiement is raspberry pi zero -w) I created one file in that directory run-pip3.sh. The following contents are there in that file pip3 install adafruit-circuitpython-ads1x15 Adafruit-Blinka adafruit-io
  3. Then I tried installing python packages and supervisor in the terminal while building raspberry pi OS by the following command sudo env INCLUDES=ssh,supervisor,python3-pip ./pieman.sh If I tried the above command, python packages are not getting installed. Only supervisor is installed properly. Now can you get my question what I am asking?
eugulixes commented 3 years ago

Yeah, the problem is 1) You have to create post-install under devices/rpi-b/raspbian-buster-armhf (actually in devices/rpi-zero-w/raspbian-buster-armhf but it symlinks to devices/rpi-b/raspbian-buster-armhf). 2) You're building the image for RPi 3 but not for RPi Zero W. Try sudo env DEVICE=rpi-zero-w INCLUDES=ssh,supervisor,python3-pip ./pieman.sh

Beebeejohn commented 3 years ago

Thank you. Will try like as u mentioned and check

Beebeejohn commented 3 years ago

I tried with the above commands as you mentioned. But still python packages are not getting installed

eugulixes commented 3 years ago

Attach the full build log, please. I need to see it to help you.

Beebeejohn commented 3 years ago

The building steps followed are

  1. I entered Wi-Fi SSID and password details in pieman.sh script 2.I created new folder named post-install under devices/rpi-b/raspbian-buster-armhf/. I created one file in that directory run-pip3.sh. The following contents are there in that file pip3 install adafruit-circuitpython-ads1x15 Adafruit-Blinka adafruit-io 3.Then I tried installing python packages and supervisor in the terminal while building raspberry pi OS by the following command sudo env INCLUDES=python3-pip,ssh,supervisor,DEVICE=rpi-zero-w ENABLE_WIRELESS=true ./pieman.sh

Python packages like adafruit io, adafruit blinka., etc., are not installed. Showing like no module found error while I am importing after building the image

eugulixes commented 3 years ago

No, as I mentioned above you have to create the post-install directory under devices/rpi-b/raspbian-buster-armhf (not devices/rpi-b or anything else). Please, re-read my message carefully.

Beebeejohn commented 3 years ago

I created that post-install directory under devices/rpi-b/raspbian-buster-armhf) only. I have not mentioned that full path here. I reedited that comment. Can you check that now? I tried exactly as you mentioned. But the packages are not getting installed

Beebeejohn commented 3 years ago

Can you answer my question please

eugulixes commented 3 years ago

I asked you in one of my messages above to attach the full build log. To do that, redirect stderr to a file. For example,

sudo env INCLUDES=python3-pip,ssh,supervisor,DEVICE=rpi-zero-w ENABLE_WIRELESS=true ./pieman.sh 2> buildlog

Then, attach the buildlog file. I will be able to study it and, probably, help you with your problem.

Beebeejohn commented 3 years ago

actually I did not get what is build log file. Do u mean the image which I built for built log file?

eugulixes commented 3 years ago

I gave an example of how to get the build log file. Please, re-read my message carefully. In that example the log file is called buildlog.

Beebeejohn commented 3 years ago

Please find my build log file buildlog.zip

  1. I tried with this command sudo INCLUDES=ssh,python3,python3-dev,python3-pip,python3-smbus,i2c-tools,nano,python-meld3,supervisor,raspi-config DEVICE=rpi-zero-w ENABLE_WIRELESS=true ENABLE_UNATTENDED_INSTALLATION=true ./pieman.sh 2> buildlog
  2. These contents are there in run-pip3.sh file which is created in devices/rpi-b/raspbian-buster-armhf/post-install pip3 install board jsonlib-python3 sockets supervisor RPi.GPIO pyserial pyusb Adafruit_PureIO pyftdi Adafruit-PlatformDetect sysv-ipc rpi-ws281x Adafruit-Blinka adafruit-circuitpython-busdevice adafruit-circuitpython-ads1x15
Beebeejohn commented 3 years ago

Can you answer my question?

eugulixes commented 3 years ago

According to the logs here's the problem: WARNING: The directory '/home/yamuna-b/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

It seems there is a bug in Pieman.

eugulixes commented 3 years ago

I will check it these weekends.