0

I have this very basic piece of Python which I use to visualize some data and perform a few interactions with. I launch it from Spyder and it is basically just a function. In broad terms:

  • open a file and create a DataFrame from it

  • plot some data and add a few sliders to interact with the data

I was wondering whether I could make this small code available to other people who do not have Python installed and probably not even the latest Qt5 libs I am using.

Os would be Linux but could also be Windows if it came easier.

Can you tell me how time consuming would it be to create a standalone file which could be double clicked and just show the plot with the interactive bits?

Michele Ancis
  • 1,265
  • 4
  • 16
  • 29
  • 1
    This [answered question](http://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency) describes a few ways to make a standalone executable from python code. Not sure if the solutions there would help you distrubute Ipython though, but it sounds like you may not need to. It doesn't look too involved. – Walton Mar 30 '17 at 22:27
  • Thanks! It looks like there's a couple of options out there. I was trying to estimate the effort and by the looks of it, I think I'd need a couple of days to figure it out - being the noob I am. – Michele Ancis Mar 30 '17 at 22:31
  • 1
    a couple of options are mentioned in the following discussion: http://stackoverflow.com/questions/12339671/how-to-compile-python-script-to-binary-executable – Marcus Mar 31 '17 at 07:48

1 Answers1

1

Just followed the (2 line!) instructions on PyInstaller:

$ echo "print 'hello world...'" > helloworld.py
$ pip install pyinstaller
$ pyinstaller helloworld.py
$ dist/helloworld/helloworld 
hello world...

Looks pretty automated. It analyses your dependencies as far I can tell and brings everything you need together and then makes a launch script. It works on loads of platforms and even mentions Qt on the front page. I reckon its worth a go!

Walton
  • 506
  • 4
  • 8
  • Looks like it! Only bother on my side is that I can't use `pip` as the machines I work on are not on the 'net, so I'll have to find a way to install `PyInstaller` in some other way.. – Michele Ancis Mar 30 '17 at 23:00
  • 1
    From [the pip manual](https://pip.pypa.io/en/stable/reference/pip_download/): "`pip download` does the same resolution and downloading as `pip install`, but instead of installing the dependencies, it collects the downloaded distributions into the directory provided (defaulting to the current directory). This directory can later be passed as the value to `pip install --find-links` to facilitate offline or locked down package installation." If your download machine and your offline one are the same os and whatnot then it should just work, otherwise you'll need to read the instructions! – Walton Mar 30 '17 at 23:11
  • Yes that's a little bit the problem: I could download from a Win machine but the Linux I'd like to install the package on can't see the net. RTFM is probably the only way :-) – Michele Ancis Mar 31 '17 at 07:10
  • It **does** work for `hello world`, but for a simple plot with `matplotlib` it does not :( – Michele Ancis Apr 01 '17 at 22:40
  • Hmm, matplotlib is mentioned on the front page and is in the list of [supported packages](https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages). A search for PyInstaller on SO brings up >1300 questions; 130 of which include matplotlib. Suggest searching for your error message or whatever it is that doesn't work. – Walton Apr 02 '17 at 23:26
  • I've done it. Believe it or not, I wasn't able to find how to solve it. I end up in git discussions where it looks like a solved issue, except it's not. http://stackoverflow.com/questions/43163201/pyinstaller-syntax-error-yield-inside-async-function-python-3-5-1 – Michele Ancis Apr 03 '17 at 00:00
  • That's awesome. Pretty annoying to have hit a bug like that though. – Walton Apr 05 '17 at 22:13