5

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.

Oxymoronica
  • 111
  • 2
  • 4
  • 10

3 Answers3

8

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, …)

Valentin Lorentz
  • 9,556
  • 6
  • 47
  • 69
  • WOW I'M AN IDIOT. Lol! I guess it shows that I'm a beginner and I haven't been doing this in months. Suuuuuuuuper embarrassing. Thank you so much, haha! No wonder no one else was having problems that I could find... – Oxymoronica May 19 '16 at 18:14
1

Run It In CMD

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
Jaidee
  • 929
  • 12
  • 5
0

Ensure your script doesn't has any syntax errors. If it's so, then pyinstaller will rethrow the exception and this could be one of the reason.

Jayaprakash
  • 703
  • 6
  • 15
  • My script doesn't throw any syntax errors, it appears to run just how I want it to. That's interesting, though, I didn't know that PyInstaller would do that. – Oxymoronica May 18 '16 at 16:51
  • 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. – Oxymoronica May 18 '16 at 17:31