1

I'm facing a not understandable error when I'm launching my Python script on my ftp server via PHP, which is the following:

Traceback (most recent call last): File "./data.py", line 9, in import urllib.request File "/home/www/urllib/request.py", line 88, in import http.client File "/home/www/http/client.py", line 1063 chunk = f'{len(chunk):X}\r\n'.encode('ascii') + chunk \ ^ SyntaxError: invalid syntax SyntaxError: invalid syntax

Would you have any idea? I have no clue about this. I've checked out the "http.client.py" but can't find any issue with this part of the code.

Many thanks

sammtt
  • 401
  • 1
  • 6
  • 14
  • I'm not a python dev, but it may have to do something with your python version. I recall 2.7 being some kind of thing vs 3.x versions. Downgrade or update your local working python version maybe you can reproduce the error locally – R_Ice Sep 11 '17 at 23:09
  • I've developed everything using Python 3.6 and installed every package for 3.6. What can be the issue? – sammtt Sep 11 '17 at 23:16
  • maybe your server is running a 2.x version of python (just a shot in the dark) – R_Ice Sep 11 '17 at 23:18
  • If the interpreter says there is a syntax error at the beginning of a line, then the error is most likely before this line, probably a missing bracket/parenthesis. You should check the code before this line. – Unatiel Sep 11 '17 at 23:19
  • ssh to your server and run 'python -V' just to rule out version problems – R_Ice Sep 11 '17 at 23:20
  • You say 'launching', can you paste your code that you use to call the python script. Is this a linux or windows server? On a linux server, you usually have python2 and 3 installed and need to specify the 3.x call by saying 'python3 ...' Better yet, take the time to learn how to use virtual environments - it will save you so many of these types of headaches. – SteveJ Sep 11 '17 at 23:34

0 Answers0