UPDATE: Actually, now I have checked, and PyInstaller is saying Invalid Syntax for EVERY script I have, even ones that I have previously packaged with PyInstaller without any issues. I uninstalled and reinstalled PyInstaller, but it's still having the same problem. Is PyInstaller not compatible with Python 3.5.1? That's the only thing I can think of that I might have updated between now and when everything was working fine
Original Question: I'm sure there is a really simple and stupid answer for what I'm doing wrong, because I can't seem to find any other cases of people having this problem.
I have a script I want to package into a standalone executable. In the past, I have used PyInstaller with minimal hassle. Py2exe and cx_freeze have never worked for me. I'm using Python version 3.5.1 and PyInstaller version 3.2, which I believe is the current version since I just uninstalled and reinstalled.
The command I am trying to use is so simple I feel like an idiot for having trouble.
pyinstaller --onefile myscript.py
File "<stdin>", line 1
pyinstaller --onefile myscript.py
SyntaxError: invalid syntax
It's giving a generic SyntaxError: invalid syntax
even though that is the exact command straight from the PyInstaller docs.
To be sure, I also tried to include the entire path to my script in the command, added and took out quotation marks, and tried every variation I could think of but it gives me the same syntax error every time.
I'm pretty much a beginner, so any really advanced fixes will go over my head. But like I said, I assume it's something silly I've missed. Thanks in advance.
The syntax error is caused by your command itself, not by the code it calls.
This part is very indicative:
File "<stdin>", line 1
pyinstaller --onefile myscript.py
You actually tried to run that command in a Python shell.
But it is not Python code. You should run it in a usual shell (cli.exe, bash, …)
Why are you running it in python shell? It's a problem with python syntax because it is not even defined.
>>> pyinstaller --onefile myscript.py
And, by the way. You are not even importing the PyInstaller module. Run this line on your CMD:
pyinstaller --onefile filename.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With