Blynk RPI 3 Model B+ connect to local server

Yeap I made it all working!
I used an example from the examples folder and replaced the auth and the

blynk = BlynkLib.Blynk(BLYNK_AUTH)

with this:

blynk = BlynkLib.Blynk(BLYNK_AUTH, ‘192.xxx.x.xx’, 8080)

and with this way it connects to the local server (so it connects to itself :stuck_out_tongue_closed_eyes: )

Now if I run the command

python2.7 /home/pi/blynk-library-python/examples/02_virtual_read.py

it works correctly! without any errors…
But as far as the final ( I hope ) problem I’ve installed the library but it still returns the error…any suggestions ?

So that command works in a CLI, but not in rc.local

Doesn’t make sense to me, at least not with the error you are getting… which implies that the rc.local command IS actually working, but the library path is invalid when the script is ran that way.

Linux gives me headaches :stuck_out_tongue:

oh that’s SOOOOOO TRUE (im from Greece and now in Greece its 3:13 AM im trying to find a solution for at least 6 hours…)

After searching I found this:

and then you wrote import BlynkLib in the promt… so I checked if it works and it does…
so python 2.7 promt accepts to import the library but python 2.7 doesn’t accept it. I don’t know what to do anymore… should I ask in a RPI forum ? is this irrelevant to the Blynk forum?

Mastering (OK, even trying to guess) how python paths work was a challenge… not sure if I somehow fixed something or not by completely removing all traces of the Blynk library and reinstalling… but I just started opening, editing and running my python scripts with IDLE (for Python 2) and it just works… I haven’t bothered running any of them at boot yet as they are just experiments right now.

Shouldn’t hurt… as I am probably one of the rare members here that even use Blynk Python, And seemingly the only one who answers Python or NodeJS related questions :stuck_out_tongue_winking_eye:

Well all the tests that I’ve done are with python 2 and not python 3 so I don’t think that this is the problem…

I have never tried Python 3 myself… but I understand it is mainly different syntax that would cause issues… nothing like what you are running into… that seems mostly path related.

Perhaps add in the actual path to the import BlynkLib in your script?

Some light reading :stuck_out_tongue:

https://leemendelowitz.github.io/blog/how-does-python-find-packages.html

On my system, opening up IDLE and checking the Path Browser, I can see the correct path for my BlynkLib.py file

Compare with yours.

Then the question is, will running Python from CLI vs. rc.local use a different path 'guide"??

Well the time is 4:19 Am and i think I found the solution!! What I needed to do is to put the example script in the same folder with the BlynkLib… (That’s the moment when the solution is under your nose) now it works correctly no errors and it runs automatically on reboot… I have to say a big thank you Gunner for the help!
Also RPI is good but not good enough for the headaches that it gave to me…

Also no they use the same path guide,
In terminal if you put sudo they use the same path with the rc.local
And if you don’t the command runs like it is in the IDLE

In IDLE was working just fine, the terminal (and rc.local) was the problem

Good solution!

I tested with my rc.local and had same ImportError: No module named issue. Nothing else I Googled and tried worked for me either.

I like to keep my scripts organised… so I instead made copies of BlynkLib.py & BlynkLib.pyc and placed them into my scripts folder. Now I can run on boot or manually for development via IDLE :smiley: