Python Forum
SyntaxError: invalid syntax ??
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: invalid syntax ??
#11
(Jan-24-2022, 10:56 AM)korenron Wrote: this is an old PI3 , maybe I can't make it work ?
Which version did you install?
The newest is python 3.10 or python 3.9.5 as used in tutorial?
What folder do cd into after extracted files?
To run directly
python3.10 myscript.py
# Or
python3.9 myscript.py
(Jan-24-2022, 10:56 AM)korenron Wrote: but how can I do it for this part:
data_byte = b'123'
data_temp = ["{:02X}".format(byte) for byte in data_byte]
print(data_temp)
Output:
['31', '32', '33']
Reply
#12
I have install the latest
Python-3.9.10
and it's in this folder
/Python-3.9.10 $
when I try to run it
I get error "ModuleNotFound "
 python3.9 ReadCanbus.py
Traceback (most recent call last):
  File "/home/pi/ReadCanbus.py", line 1, in <module>
    import can
ModuleNotFoundError: No module named 'can'
while running python3 - will work

and I did what you told me - and it's seem to be working

so thank you !
Reply
#13
(Jan-25-2022, 09:37 AM)korenron Wrote: I have install the latest
Python-3.9.10
That's fine,as info the lasted version is Python 3.10
(Jan-25-2022, 09:37 AM)korenron Wrote: I get error "ModuleNotFound "
When have a new version most install all 3-party packages that you use to this version.
Do a test of python and pip from command line,that use right version.
python --version 
# Or 
python3 --version 
 
pip --version 
# or 
pip3 --version
Installation python-can 3.3.4
pip install python-can
# Or
python3 -m pip install python-can
Reply
#14
maybe I'm missing somethig
pi@localhost:~ $ nano -c ReadCanbus.py
pi@localhost:~ $ python --version
Python 2.7.13
pi@localhost:~ $ python3 --version
Python 3.5.3
pi@localhost:~ $ pip --version
pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
pi@localhost:~ $ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
pi@localhost:~ $ python3 -m pip install python-can
Collecting python-can
  Using cached https://www.piwheels.org/simple/python-can/python_can-3.3.4-py2.p              y3-none-any.whl
Collecting wrapt~=1.10 (from python-can)
  Using cached https://www.piwheels.org/simple/wrapt/wrapt-1.13.3-cp35-cp35m-lin              ux_armv7l.whl
Collecting aenum (from python-can)
    100% |גגגגגגגגגגגגגגגגגגגגגגגגגגגגגגגג| 133kB 502kB/s
Installing collected packages: wrapt, aenum, python-can
Successfully installed aenum-3.1.8 python-can-3.3.4 wrapt-1.13.3
when I run the code using python3 - everything is working
isn't Python3.9 need to use the same packages from pip3 as Python3 ?
Reply
#15
Is still use the old version
Try:
python3.9 --version
If that point to Python 3.9
Install with.
python3.9 -m pip install python-can
Then you most always use python3.9 my_script.py

Look search for alias change if want all to point to one version.
Make Python3 as Default in Ubuntu Machine
Reply
#16
I get error
ERROR: Could not find a version that satisfies the requirement python-can (from versions: none)
ERROR: No matching distribution found for python-can
starnge

but never mind - this is an old PI, just for testing
thank you for all the help and the answer

I didn't know that python3.9 is not the same as python 3 and 3.5
I thought it will be update auto

Thanks you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print(data) is suddenly invalid syntax db042190 6 1,196 Jun-14-2023, 02:55 PM
Last Post: deanhystad
  Invalid syntax with an f-string Mark17 7 7,820 Jan-14-2022, 04:44 PM
Last Post: Mark17
  invalid syntax in my class CompleteNewb 2 1,905 Dec-13-2021, 09:39 AM
Last Post: Larz60+
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 3,169 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Unexplained Invalid syntax Error cybertooth 5 3,255 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  [split] SyntaxError: invalid syntax Code_X 3 2,759 May-04-2021, 05:15 PM
Last Post: Yoriz
  Invalid syntax error - need help fixing calgk01 3 3,283 Feb-23-2021, 08:41 PM
Last Post: nilamo
  Invalid syntax using conditionals if - else jperezqu 1 2,334 Jan-13-2021, 07:32 PM
Last Post: bowlofred
  invalid syntax in line 5. Help Asadzangibaloch 2 2,392 Dec-10-2020, 04:26 PM
Last Post: deanhystad
  Error on nested loop : Invalid syntax dvazquezgu 3 3,236 Nov-25-2020, 10:04 AM
Last Post: palladium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020