Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing python packages while building custom Raspberry pi OS #280

Open
Beebeejohn opened this issue Nov 17, 2020 · 25 comments
Open

Installing python packages while building custom Raspberry pi OS #280

Beebeejohn opened this issue Nov 17, 2020 · 25 comments

Comments

@Beebeejohn
Copy link

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

@eugulixes
Copy link
Contributor

  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
Copy link
Author

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
Copy link
Contributor

  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
Copy link
Author

Beebeejohn commented Nov 18, 2020

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
Copy link
Contributor

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
Copy link
Author

ya ok thank you

@Beebeejohn Beebeejohn reopened this Dec 4, 2020
@Beebeejohn
Copy link
Author

Beebeejohn commented Dec 4, 2020

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
Copy link
Author

Can anyone pls answer my above question?

@eugulixes
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

Beebeejohn commented Dec 7, 2020

Thank you. Will try like as u mentioned and check

@Beebeejohn
Copy link
Author

Beebeejohn commented Dec 8, 2020

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

@eugulixes
Copy link
Contributor

eugulixes commented Dec 8, 2020

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

@Beebeejohn
Copy link
Author

Beebeejohn commented Dec 8, 2020

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
Copy link
Contributor

eugulixes commented Dec 8, 2020

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
Copy link
Author

Beebeejohn commented Dec 8, 2020

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
Copy link
Author

Can you answer my question please

@eugulixes
Copy link
Contributor

eugulixes commented Dec 9, 2020

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
Copy link
Author

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

@eugulixes
Copy link
Contributor

eugulixes commented Dec 9, 2020

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
Copy link
Author

Beebeejohn commented Dec 10, 2020

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
Copy link
Author

Can you answer my question?

@eugulixes
Copy link
Contributor

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
Copy link
Contributor

I will check it these weekends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants