Python Forum
Create Python "Executable" from PyCharm?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create Python "Executable" from PyCharm?
#1
Is it possible to create a standalone python "application" using PyCharm on the mac?

I see a setup.py with lots of options under PyCharm's Tools menu, but the only thing I've been able to get to work is to create an "egg" file, which does not have the library dependencies.

I was hoping for something like an executable JAR file (compiled or maybe just python files but with all the dependencies right inside the file).

I tried to install the separate Pyinstaller, but the pip install crashed.

Not sure how to do build a project for a user.

Thanks in advance,
Reply
#2
PyCharm can help. It can create the setup.py file help->find Action->packaging
and the basic package structure: https://www.jetbrains.com/help/pycharm/c...kages.html
also see: https://blog.jetbrains.com/pycharm/2017/...e-on-pypi/
Reply
#3
Thanks, but I don't want to "publish" the code, just create an executable I can run locally without worrying about dependencies.

Perhaps I don't quite get what's meant by "publishing" when it comes to Python?

I'm thinking "executable JAR" -- where all the dependencies are in the JAR and I can run it like this:

$java -jar somejarfile.jar

(of course, the python equivalent, not a Java JAR.)

Thanks again. :)
Reply
#4
for that you want py indtaller: https://pypi.python.org/pypi/PyInstaller/3.3.1
and: http://www.pyinstaller.org/

I believe you will need to run this outside of the IDE.
Reply
#5
(Jan-05-2018, 11:39 PM)Oliver Wrote: I'm thinking "executable JAR" -- where all the dependencies are in the JAR and I can run it like this:
The closest in python is wheel.
You make a wheel file that contain all dependencies.
So if you or some else will use this wheel(.whl) file,install it like this pip install wheel_name
I have tutorial about this here.

Oliver Wrote:I tried to install the separate Pyinstaller, but the pip install crashed.
What did you do,it's just pip install pyinstaller
Do it from command line,i know PyCharm has build in setup for this,but if error always command line.

Here i have a post with pyinstaller.
I always use virtual environment with Pyinstaller when there is a lot dependencies.
Then it make not difference if Pyinstaller crash on my OS,virtual environment is like a new Python installation.
Reply
#6
I got pyinstaller to work from the command line, but that's python 2.7.

Trying to get it to work in PyCharm wasn't as easy. Still stuck there.

In PyCharm, I installed PyInstaller and PyInstaller "hooks".

Then, I created a setup.py file with this:

import PyInstaller as pyinstaller
from binaryfilesearch import SearchBinaryFile
pyinstaller SearchBinaryFile.py
But, in this case, I got this:

pyinstaller SearchBinaryFile.py
                               ^
SyntaxError: invalid syntax
I don't need to create an executable on the Mac for all the code in the project, just this one py file. I'm probably close now.

Any ideas how to make PyInstaller work inside PyCharm?

Thanks,

(Jan-06-2018, 12:40 AM)snippsat Wrote:
(Jan-05-2018, 11:39 PM)Oliver Wrote: I'm thinking "executable JAR" -- where all the dependencies are in the JAR and I can run it like this:
The closest in python is wheel.
You make a wheel file that contain all dependencies.
So if you or some else will use this wheel(.whl) file,install it like this pip install wheel_name
I have tutorial about this here.

Oliver Wrote:I tried to install the separate Pyinstaller, but the pip install crashed.
What did you do,it's just pip install pyinstaller
Do it from command line,i know PyCharm has build in setup for this,but if error always command line.

Here i have a post with pyinstaller.
I always use virtual environment with Pyinstaller when there is a lot dependencies.
Then it make not difference if Pyinstaller crash on my OS,virtual environment is like a new Python installation.

pip install pyinstaller

crashed at the end.

I did finally get it to install.

Thank you.
Reply
#7
I dont believe there is a setup.py file with pyinstaller. you just execute pyinstaller on your python script that starts your program.

Quote:pyinstaller SearchBinaryFile.py
You wouldnt of done this anyways, because you are putting a terminal commmand into a python script. It doesnt make sense.

https://mborgerson.com/creating-an-execu...on-script/
Reply
#8
The answer is very simple you never do this to from a Editor/IDE.
Even if PyCharm has build in is stuff for this,i would never use it.
Always use command line for stuff like this.

For difficult project like this where want to build .exe with Pandas(has a lot of dependencies).
I would always build it in virtual environment,to have all dependencies in one place.
Make it a lot easier to troubleshoot,as i do in this post.
Reply
#9
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No hold('on') in pycharm python 3.7 Vedant 0 571 Sep-13-2019, 01:51 PM
Last Post: Vedant
  Python 3.6 to executable DeGerlash 14 10,612 Jan-16-2018, 01:49 PM
Last Post: DeGerlash

Forum Jump:

User Panel Messages

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