Problems when running python code on raspberry pi 4b

January 11, 2024, 21:53

xzors3

I've been trying to connect a raspberry pi 4b to ads1115 for a few days now. I've never worked with this board before and I'm totally new to this. The wiring is correct from what I have seen on the internet, but when I download the library from the Adafruit ADS1X15 I get an error when running the code. I work with Python and operating system is Raspberry OS Lite. I have tested the board with Arduino and C++, it works without any problems. This is part of my thesis project and I would appreciate your help.

xzors3

I will upload screenshots in 10 mins

dutchslav

Ping me when you've sent it

xzors3

Ok

xzors3


xzors3

<@1063554880121348117>

dutchslav

Did you try what it said

xzors3

yes and it cant find the package

dutchslav

apt update

xzors3

tried and didn't work

dutchslav

apt update doesn't work?

xzors3

yes

dutchslav

The command itself?

xzors3

ops

xzors3

it updated

xzors3

but still can't find the library in python

dutchslav

Got it

dutchslav

What you're going to do

dutchslav

sudo apt install python3-full

dutchslav

python3 -m venv venv

dutchslav

Then in the venv directory

dutchslav

Search a "activate" file

dutchslav

And source it

xzors3

okk

xzors3

its just "activate"

xzors3

without any format

xzors3

right

dutchslav

Yeah

xzors3

ok i found it

dutchslav

source activate

xzors3

and what should i do with it cause i didn't understand 🥲

dutchslav

This

xzors3

i did it

xzors3

now i have (venv)

dutchslav

Now run the first command again

dutchslav

With the pip install

xzors3

its downloading somethingg

dutchslav

Good

xzors3

but why i have to use virtual enviro

dutchslav

Idk

dutchslav

The command said it

xzors3

I've seen it on the internet but it sounded hard for me

dutchslav

Does it work now?

xzors3

now i have another error

xzors3


dutchslav

pip install that module

xzors3


dutchslav

This again

xzors3

run this "pip install adafruit_ads1x15" again?

dutchslav

Yeah

xzors3

still the same

dutchslav

Lemme check rq

xzors3

okk

dutchslav

<@257436237466566656> you installed the library

dutchslav

And it says that library isn't found?

xzors3

yes

dutchslav

Then you should try opening a GitHub issue

dutchslav

Sorry that i can't help you

xzors3

its okay

xzors3

thanks a lot

xzors3

<@1063554880121348117>

xzors3

I fixed it

xzors3

Now it imports the library without problems

oops.se

Could you share the "fix"!

xzors3

If I'm honest with you, I have no idea how i solved it. I've read a lot of forums and saw that
sudo python3
and
python3
are somehow different commands. I know that sudo executes the command as root but this time was different. Also, i used venv.

xzors3

Then I had problem with i2c because the 0x48 is always in use. And i found out that if i disable i2c and then enable it, i can use this address for my ADS1115.

xzors3

Still looking for another solution but it works for now