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

Python version confusion #41

Open
HilmarSt opened this issue May 16, 2024 · 3 comments
Open

Python version confusion #41

HilmarSt opened this issue May 16, 2024 · 3 comments

Comments

@HilmarSt
Copy link

HilmarSt commented May 16, 2024

I was using a Pi Zero W with Python 3.9 :

$ python --version
Python 3.9.2

After following the "Quick installation of pigpio on Raspbian:" in README.md :

$ sudo apt-get update    
$ sudo apt-get install pigpio python-pigpio python3-pigpio

the default Python version changed to 2.7 :

$ python --version
Python 2.7.18

Calling simple-receiver.py with "python" gives an error:

$ python simple-receiver.py
  File "simple-receiver.py", line 34
    print(f'Invalid address {address}. Addresses must be between 3 and 5 ASCII characters.')

...but works with "python3"

$ python3 simple-receiver.py
Python NRF24 Simple Receiver Example.
Connecting to GPIO daemon on localhost:8888 ...

Which of the packages in "sudo apt-get install pigpio python-pigpio python3-pigpio" are necessary to have the example working without automatically installing Python v2.7 ?

update:

$ sudo apt-get install python-is-python3

The following packages were automatically installed and are no longer required:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2 python2-minimal python2.7 python2.7-minimal
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python-is-python2 python-pigpio
...

$ python --version
 Python 3.9.2

$ python simple-receiver.py
... works
@bjarne-hansen
Copy link
Owner

I'm not sure what caused your initial problem.

In general: try to read the following on selecting the Python version on Linux:

https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux

//bjarne

@bjarne-hansen
Copy link
Owner

... and by the way: the reason the example only works with Python3 is the f-string used.

//bjarne

@HilmarSt
Copy link
Author

The initial problem was caused by "sudo apt-get install pigpio python-pigpio python3-pigpio" from the README.md .
It seems that one package requires Python 2 and is not necessary, I think it's "python-pigpio".
So you may adapt your documentation to "sudo apt-get install pigpio python3-pigpio".

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