sitespeedunder.blogg.se

Make a python script executable for mac and windows
Make a python script executable for mac and windows





  1. #Make a python script executable for mac and windows mac os#
  2. #Make a python script executable for mac and windows install#
  3. #Make a python script executable for mac and windows update#

#Make a python script executable for mac and windows mac os#

Python can be installed on Windows, Linux, Mac OS as well as certain other platforms such as IBM AS/400, iOS, Solaris, etc.

#Make a python script executable for mac and windows install#

streamlit and main.py into dist direcoty.Next Install Python on Windows, Mac, and Linux The executable file created above does not work alone. Finally, execute pyinstaller -onefile -additional-hooks-dir=./hooks run_main.spec -clean.Add the following lines to cli.py contained in the streamlit distribution, e.g.Now, I found a solution without 404 not found error.Īfter that, suppose we want to make an executable file from the following main.py: The command line shows streamlit is running, but unfortunately the browser can’t seem to find the page (at the ip) on localhost, and gives a 404 not found error. Then run the compiled app with: $ dist/streamlit_run Now, to compile the app, run: $ pyinstaller -onefile -additional-hooks-dir=. Pyinstaller couldn’t find streamlit on its own, so I had to add hook-streamlit.py: from import copy_metadataĪnd then streamlit_run.py is a wrapper for the app, that essentially calls streamlit run example.py: import sys

make a python script executable for mac and windows

The env.yml is for the conda environment: name: streamlit-build-test I created an example project like so: streamlit-build-test/ What do I need to modify to ensure that streamlit is satisfied that it has been properly installed when running from an executable? I get the feeling that modifying def _global_development_mode(): to always return True is probably a dangerous idea. This is obviously the wrong behaviour on streamlit’s part, pyinstaller has almost certainly bundled everything correctly but streamlit is looking in the wrong place to check if it has been installed correctly. This call works normally when using either streamlit run pythonScript.py or python streamlitWrapper.py but (for whatever reason), once pyinstaller bundles streamlit into the executable, the above check fails and sends streamlit into development mode, and things stop working as expected. If config.get_option("velopmentMode") and config.get_option( This is different from the URL that will be used to connect to the That is, this is the port where static assets will be served from. """Get the report URL that will be shown in the browser's address bar. This is called from Report.py which has the effect of setting the port to 3000: def _get_browser_address_bar_port(): This option defaults to True if and only if Streamlit wasn't installed Basically everytime streamlit is run, at some time the following is executed in config.py: visibility="hidden", type_=bool) I have discovered the reason why when using the bundled executable my web browser doesn’t load properly, it is due to a check performed in streamlit to establish whether streamlit was properly installed. The problem now is, the pyinstaller executable starts streamlit on port 3000 instead of port 8501 and my browser (for reasons I don’t understand) can’t run my script when using streamlitWrapper.exe (this is the default name of the executable pyinstaller will produce), running python streamlitWrapper.py works exactly the same as when calling streamlit run pythonScript.py, but for some reason the pyinstaller executable doesn’t exactly replicate the functionality you get when running python streamlitWrapper.py. If version.should_show_new_version_notice():Īfter all that, you can run your script using the usual python call python streamlitWrapper.py.Īnd with some massaging you should receive an executable. Streamlit._is_running_with_streamlit = TrueĬredentials.get_current().check_activated(auto_resolve=True) You will also need to edit the file cli.py contained in the streamlit distribution to include the following def: def _main_run_clExplicit(file, command_line, args=): Save the 7 lines above into another script called streamlitWrapper.py (or any other name). Streamlit.cli._main_run_clExplicit('pythonScript.py', 'streamlit run') I created the following wrapper script to allow any script utilitzing streamlit to be run by calling

make a python script executable for mac and windows

#Make a python script executable for mac and windows update#

UPDATE Not yet solved, but almost, further help appreciated!!!







Make a python script executable for mac and windows