Python Forum
Using PyInstaller in PyCharm
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using PyInstaller in PyCharm
#1
This question might have gotten lost in the other thread so here it is again.

I was able to get PyInstaller to work from the command line (thanks for the replies!), but that's only for Python 2.7.

So now, I'm trying to get it working inside PyCharm, but so far, not quite.

I've imported both PyIntaller and PyInstaller Hooks.

My setup.py code looks like this:

import PyInstaller as pyinstaller
from binaryfilesearch import SearchBinaryFile

pyinstaller  SearchBinaryFile.py
Yet, I get a ...

setup.py", line 4
pyinstaller SearchBinaryFile.py
^
SyntaxError: invalid syntax


=====

Any suggestions on what I need to do I can build a standalone file using PyInstaller within PyCharm (so I can use 3.6 with f-strings, etc.)?

Thanks again.

- O
Reply
#2
I don't know why it has to work from within PyCharm.
All pycharm can do it run the OS version.
That's an IDE, not an OS. If it works from command line, use that.
And if it won't work for python 3, you probably need a python 3 version.
Reply
#3
Command line seems like the way to go. Just making sure.

So, I have python3 installed, and I installed Pyinstaller within the IDE for Python3, but how would I run pyinstaller under python3 at the command line when the default python at the command line is 2.7?
Reply
#4
Here are the options:
M:\python\a-d\c\CaliforniaPublicSalariesModified
λ pyinstaller
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
                   [--add-data <SRC;DEST or SRC:DEST>]
                   [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
                   [--hidden-import MODULENAME]
                   [--additional-hooks-dir HOOKSPATH]
                   [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                   [--key KEY] [-d] [-s] [--noupx] [-c] [-w]
                   [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                   [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                   [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                   [--win-no-prefer-redirects]
                   [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--runtime-tmpdir PATH] [--distpath DIR]
                   [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a]
                   [--clean] [--log-level LEVEL]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname
Reply
#5
Adding Pyinstaller to PyCharm can be done by adding it as an external tool:

Adding tool:
------------

  1. In Pycharm - File->Settings->Tools->External Tools
  2. Click on the '+' sign to add a new tool (if it is the first tool you add, just fill the form, no need for the '+')
  3. Fill the fields:
    Name: Pyinstaller
    Description: Generate a single executable
    Program: \pyinstaller.exe $FileName$ (Make sure that Pyinstaller is recognized in PyCharm Project...)
    Arguments: --onefile
    Working directory: $FileDir$\dist


Using the tool
--------------

In PyCharm: Tools->External Tools->Pyinstaller

The exe file will appear on a dist subfolder of the .py file folder
Reply
#6
(Jan-13-2019, 12:11 PM)DarkLight Wrote: --some errors reported - so I update:
Adding Pyinstaller to PyCharm can be done by adding it as an external tool:

Adding tool:
------------

  1. In Pycharm - File->Settings->Tools->External Tools
  2. Click on the '+' sign to add a new tool (if it is the first tool you add, just fill the form, no need for the '+')
  3. Fill the fields:
    Name: Pyinstaller
    Description: Generate a single executable
    Program: C:\Users\[your_user_here]\AppData\Roaming\Python\Scripts\pyinstaller.exe (Make sure that Pyinstaller is recognized in PyCharm Project...)
    Arguments: --onefile $FilePath$
    Working directory: $FileDir$


Using the tool
--------------

In PyCharm: Tools->External Tools->Pyinstaller

The exe file will appear on a dist subfolder of the .py file folder
Reply
#7
So, I did the virtual environment install and set up the external tools as shown.
However, I'm getting:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

When I try to run it.
Reply


Forum Jump:

User Panel Messages

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