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

AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'? #76

Open
abdul-rehman-2050 opened this issue Jun 15, 2023 · 3 comments

Comments

@abdul-rehman-2050
Copy link

I am trying to run the example code on Windows 10 and when simple import cause this error

import BlynkLib
Traceback (most recent call last):
File "<pyshell#8>", line 1, in
import BlynkLib
File "C:\Program Files\Python311\Lib\site-packages\BlynkLib.py", line 49, in
/___/ for Python v""" + _VERSION + " (" + os.uname()[0] + ")\n")
AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'?

@ebolisa
Copy link

ebolisa commented Jun 15, 2023

I am trying to run the example code on Windows 10 and when simple import cause this error

AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'?

You're using the wrong library!

print("""
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \\/  '_/
 /____/_/\\_, /_//_/_/\\_\\
        /___/ for Python v""" + __version__ + " (" + sys.platform + ")\n")

test code:

from __future__ import print_function

import BlynkLib
import errno
import socket
import time
from BlynkTimer import BlynkTimer

BLYNK_AUTH = '-------'
blynk = BlynkLib.Blynk(BLYNK_AUTH)
timer = BlynkTimer()
cnt = 0

def update_virtual_led():
  global cnt
  if(cnt%2 == 0): #check for even number
    blynk.virtual_write(10, 0)
    time.sleep(.1)
  else:
    blynk.virtual_write(10, 255)
    time.sleep(.1)
  cnt += 1


def uptime():
  blynk.virtual_write(0, round(time.time() / 1000, 2))


@blynk.on("connected")
def blynk_connected(ping):
    print('Blynk ready. Ping:', ping, 'ms')
    blynk.sync_virtual()


@blynk.on("disconnected")
def blynk_disconnected():
    print('Blynk disconnected')


timer.set_interval(1, update_virtual_led) #update virtual leds 1 secs
timer.set_interval(1, uptime)


if __name__ == "__main__":
    #init() #run once
  while True:
    try:
      blynk.run()
      timer.run()
    except socket.error as e:
      if e.errno != errno.EPIPE:
        print("msg from blynkmain @ " + str(dt.now()))
        raise
        #blynk.connect()

@abdul-rehman-2050
Copy link
Author

I installed it with the pip command mentioned in the readme and the os still cause the error. But then I copied the BlynkLib.py file and placed it in the same folder of the testing code and it works. I am new to this and not sure why and how it works with the source file rather then the pip installed version.

@ebolisa
Copy link

ebolisa commented Jun 16, 2023

the pip installed version.

What that did is pulling the lib from a different git. “os.uname” was the clue 😉

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