0.2.0 BlynkLib Python on Win10 "no attribute" errors

Newbie to forum and blynk, I probably did everything wrong so sorry in advance.
I have a project that runs flawlessly on a RPI3b with latest Raspbian and current Python BlynkLib.
I tried to port it to a Windows 10 “Stick” PC but keep getting error “Blynk” has no attribute “VIRTUAL_READ”
I have 0.2.6 BlynkLib (official I think, but there are other forks I’ve tried) installed on both Python27 and Python38 via pip/pip3 install, and I get the same behavior whether running it as Python 2 or 3. I get the Blynk “logo” when it starts so I think that means it is connecting to the server ok? But maybe Win10 is a no-go for the library? But it seems like there are newer libraries so maybe I just need help on how to install them manually. Before I tear the last of my hair out I’m hoping someone has run into this and has a fix.
I put the applicable section of code in the backticks below.
Thanks in advance!

from datetime import datetime
import serial
import time
# Initialize Blynk
    
        BLYNK_AUTH ='**************************************'  #For Project
        blynk = blynklib.Blynk(BLYNK_AUTH,server='xxx.xxx.xxx.xxx', port=xxxx)

        # Register Virtual Pin - Read Live Stats
        @blynk.VIRTUAL_READ(50)
        def my_read_handler():
             currentTime = datetime.now()
             blynk.virtual_write(50, currentTime.strftime("%d/%m/%Y %H:%M:%S"))

While I can’t speak for, or totally understand, your “port to PC” method, I was able to confirm that you have a few syntax errors in your code above.

No BlynkLib library imported :stuck_out_tongue: Could be just a typo if you were able to get the logo, as that is in the library and not an indication of connection.

Some invalid indents

blinklib.Blynk() needs the uppercase B and L in BlynkLib

And no way for the code to keep running, thus stops before printing the first display data…
Add this…

while True:
    blynk.run()

And now it also works fine on my RPi…

import BlynkLib
from datetime import datetime
import serial
import time
# Initialize Blynk
    
BLYNK_AUTH ='XA7r5kG7*******ZEXttJME5r'  #For Project*
blynk = BlynkLib.Blynk(BLYNK_AUTH,server='xxx.xxx.xxx.xxx', port=8080)

# Register Virtual Pin - Read Live Stats
@blynk.VIRTUAL_READ(0)  # vPin 0
def my_read_handler():
    currentTime = datetime.now()
    blynk.virtual_write(0, currentTime.strftime("%d/%m/%Y %H:%M:%S"))

# === Start Blynk (this call should never return) ===
while True:
    blynk.run()

Again, not quite sure what you are trying on the PC with a USB stick, but sounds like a library install issue as Windows support is shown as valid in the official Blynk Python Library.

image

Thanks so much for the quick response and great info!

Yeah my code got a little weird near the end because one of the Blynk Libraries I tried the “blynklib” really was all lower case.

I got it working after doing the following. (Hope I’m remembering all the steps, I tried a lot of stuff)

I went back to the original RPi3b project (that works without issue) to recheck versions. So in that one I was using 0.2.0 BlynkLib.py So I figured I should try and match that at least to eliminate some potential variables.

Went back to Win 10 Stick and 'pip uninstall’ed every fork of Blynk Library for both Python 2 and 3. Then I found that the only fork that I could get to do an 0.2.0 version was ‘pip install blynk-library-python’

Then I still was having issue with unknown attribute and was wondering about my env path… even though I had changed it to include Lib/site-packages for each python version, I wonder if some part of it did not propagate fully. So did a reboot.

After the reboot, partial eureka! No more unknown attribute error! But a new error emerged. “AttributeError: module ‘os’ has no attribute ‘uname’”.
So a google search revealed that some OS implementations do not include “uname” in os module. I opened up BlynkLib.py and was able to comment out the usage of uname.os and incredibly, everything started working!

Thanks again and I hope this will be useful for other Blynkers.