We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

6 posts • Page 1 of 1
bigbear11
Posts: 1
Joined: Mon Apr 28, 2025 10:04 pm

Python code for Rasberry PI

Mon Apr 28, 2025 10:11 pm

Hello,

I am a Python programmer. I have never used a Raspberry PI

I developed Python code for UAVs that uses TensorFlow, numpy, neural networks, and pandas libraries.

1. How do I upload Python code?
2. Is there a special way to upload Python libraries separately from the operational code? Libraries do not have to be re-uploaded unless the kernel dies.
3. Are there any limitations concerning software: size, etc?

I used this code successfully on a Mac with an M1 chip. There are some differences between M1 and Windows environments in running certain pieces of TensorFlow. Any suggestions and warnings will be highly appreciated.

Thank you!

DS256
Posts: 1288
Joined: Mon Jul 26, 2021 7:44 pm

Re: Python code for Rasberry PI

Tue Apr 29, 2025 12:53 am

Welcome to the forum.

Python on Raspberry PI enforces Virtual Environments which will contain all of our project code isolated from other projects and system code.

ame
Posts: 11565
Joined: Sat Aug 18, 2012 1:21 am

Re: Python code for Rasberry PI

Tue Apr 29, 2025 1:19 am

DS256 wrote:
Tue Apr 29, 2025 12:53 am
Welcome to the forum.

Python on Raspberry PI enforces Virtual Environments which will contain all of our project code isolated from other projects and system code.
Only if you don't want to use the system version of Python.
Oh no, not again.

ame
Posts: 11565
Joined: Sat Aug 18, 2012 1:21 am

Re: Python code for Rasberry PI

Tue Apr 29, 2025 1:20 am

bigbear11 wrote:
Mon Apr 28, 2025 10:11 pm
Hello,

I am a Python programmer. I have never used a Raspberry PI

I developed Python code for UAVs that uses TensorFlow, numpy, neural networks, and pandas libraries.

1. How do I upload Python code?
2. Is there a special way to upload Python libraries separately from the operational code? Libraries do not have to be re-uploaded unless the kernel dies.
3. Are there any limitations concerning software: size, etc?

I used this code successfully on a Mac with an M1 chip. There are some differences between M1 and Windows environments in running certain pieces of TensorFlow. Any suggestions and warnings will be highly appreciated.

Thank you!
Nothing special about the Pi. It's basically a Linux box.
Oh no, not again.

scotty101
Posts: 4585
Joined: Fri Jun 08, 2012 6:03 pm

Re: Python code for Rasberry PI

Tue Apr 29, 2025 2:06 pm

DS256 wrote:
Tue Apr 29, 2025 12:53 am
Python on Raspberry PI enforces Virtual Environments which will contain all of our project code isolated from other projects and system code.
Which is a very good way to bring in library dependencies such as panda, tensorflow, etc. Use a requirements.txt file in your project source and use that to create a venv with the correct libraries.

As for a special way to get the code on to the Pi, nope, choose your method. For something like this you may consider hosting your code on Github and cloning the project on to your Pi from there.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

DeaD_EyE
Posts: 247
Joined: Sat May 17, 2014 9:49 pm

Re: Python code for Rasberry PI

Wed Apr 30, 2025 10:12 pm

If you target primary RPi as target, then use the installed Python version of the OS.

If you want a newer Python version, use pyenv.
Install the required libraries, build-essental and git.

https://github.com/pyenv/pyenv/wiki#sug ... nvironment

Code: Select all

sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Then install pyenv:
https://github.com/pyenv/pyenv-installe ... le#install

Do the required steps to add the pyenv command to .bashrc or .profile.

After this stpes, you can build with the help of pyenv as a normal user a newer python version and use it as a user. Do not use it system-wide, because it will break some tool which depends on the Python version delivered by Raspberry Pi OS.

If you use e.G. `pyenv shell 3.13.3` it activates in your current terminal session Python 3.13.3.
If you install packages via pip a virtual environment is not required, but recommended.

Some packages requires additional libraries and some of them requires very long to compile on a Raspberry Pi like `lxml`.

6 posts • Page 1 of 1

Return to "Python"

AltStyle によって変換されたページ (->オリジナル) /