Maybe I must share with you my full code to your email so that you can revise it.
Otherwise, If you know, explain me how to run Dash on Public server so I can share my Dashboard with my coleagues.
Thanks.
You can follow our documentation on deploying your app: https://dash.plot.ly/deployment
I think the heroku example should be easy to follow.
Thanks for your endovoirs to help me.
@Philippe can I know why are you using find_packages()
? I find that this causes cx_freeze to import a ton of packages that are not necessary (e.g. it’s importing pandas, scipy and tensorflow on a hello world app!) any way to import only the required packages?
EDIT: It’s not find_packages, even if I remove it, cx_freeze still copies over 1GB of packages for an Hello World app… I guess I can try to use a fresh virtualenv to create the executable, otherwise I will start excluding everyhting manually… however I really don’t understand why it’s copying so much stuff!!
1GB seems wrong, I was getting 50Mb msi packages with those configs.
You can replace find_packages
with an array containing your packages name ['my_package']
.
It’s still me, with my home account.
I tried on a fresh installation of python on a different computer. Excluding tkinter on cx_freeze 5.1.1 cause all packages in the system that are not in exclude to be imported during build phase. The app will work even without specifying a single package on setup.py because the script will import everything that I have installed anyways.
This makes me think maybe you have a different version of cx_freeze? You also refer to a bdist_exe command which does not exist on 5.1.1 (can only run setup.py build to get an exe) so maybe you are not on 5.1.1?
It was with cx-Freeze==5.1.1
and python 3.6. I ran the command python setup.py bdist_msi
.
Ok, strange. I tried that in 2 machines and it brings over all the packages in the system. Same thing on a clean install of python. I guess I will try to run some more tests…
I have some updates!
-
Running cx_Freeze from a virtual environment works! It creates a much smaller folder/executable as it only brings the packages you installed in the virtualenv. HOWEVER, cx_Freeze has a bug that prevents it to work with virtualenv out of the box with some packages. Fortunately, there is a workaround here: https://stackoverflow.com/questions/14247130/cxfreeze-missing-distutils-module-inside-virtualenv
-
your executable will not be able to access your local CSS/JS/Favicon that you put in the
assets/
folder. In order to fix this, you need to create your dash app asapp = dash.Dash(__name__, assets_folder=find_data_file('assets/'))
wherefind_data_file
is defined as
def find_data_file(filename):
if getattr(sys, 'frozen', False):
# The application is frozen
datadir = os.path.dirname(sys.executable)
else:
# The application is not frozen
# Change this bit to match where you store your data files:
datadir = os.path.dirname(__file__)
return os.path.join(datadir, filename)
On top of that, you need to include the assets/
folder in your setup.py
script under includefiles
You can use the above function to read data files as well, as long as you passed them in the setup.py
files.
Hope this helps anyone in the future who wants to create Dash ‘double click’ apps!
Apisoni thanks a lot.
I did not understand the last part step where you say:
On top of that, you need to include the assets/
folder in your setup.py
script under includefiles
Please, explain to a noobie here.
Can I share my DEMO DASH code to you so you can test it and convert so that I can make sure it really works?
hi @MGBpy, what is unclear? If you are using cx_freeze, you can include static files in your app through setting includefiles
in setup.py
, it’s well documented on cx_freeze website. In dash, if you want to include local CSS/JS, you use the ./assets/
folder by default, so you need to include it in your cx_freeze app as well.
Thanks but I decided to make Dash public on heroku.
Thanks a lot
Hey Guys,
I am also using waitress, but when I try to kill the connection, I have to manually go to the command prompt, find the listening port, then kill the connection. I don’t have to do this with Flask because Ctrl + C kills the connection. Is there a way to do this with waitress? I am using waitress the same exact way as this code is presented. I know it’s a bit out of the topic, but I have been dealing with this for about 2 weeks now, and it makes things difficult with little documentation for waitress. Thanks
Hi Guys,
I am getting this error error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: https://visualstudio.microsoft.com/downloads/
can anyone share the exact link of the setup please
May be creating once your code is ready, create an executable file using pyinstaller, and in the code import Selenium and some coding opening your 127.0.0.1:8050 address for the user to get the screen open and ready for action?
I am doing a project in the free time and I was thinking in this approach as a mean for implementation, once it is ready for distribution
@MGBpy @monitorcasalab @apisoni @dayxx369 @gpahuja @Philippe
I found an easy way to convert and it works…
1: create a new python file named “run.py” in the same directory where you app.py exists.
2: the contents of run.py should be
import os
os.system(“python app.py”)
3: now Add the following code to your app.py
import webbrowser
webbrowser.get("http://your_ipaddress:portnumber ")
4: Now using the “auto-py-to-exe” convert your “run.py” which you have created in step 1 to exe
5: after completion ,run that exe file.
@nandan-nayak thanks for sharing. That does seem convenient indeed. Still, I would not recommend this approach in a corporate environment as PyInstaller is flagged as a virus by some of the mainstream corporate AVs. It should be a false positive but might get you in trouble with your security team…
Hey Im trying to acomplish the same thing however I coulndt follow your guide do you only convert run.py to exe and what else? when I do it nothing happens. Do I need to have my app in the same directory as the run.exe??
please if you can let me know!
1: you need to have “run.py” in the same directory as of “app.py”
2: the content of “run.py” is given above.
3:clone the “auto-py-to-exe” from the github ( its given above ).
4: Navigate to the folder (through CMD ) which you have cloned and extracted.
5: run" python run.py " ( run.py of auto-py-to-exe ) and it will open a GUI.
6: specify the location of your "run.py " , "one file " , " window based " and click on convert.
7: it will create a executable file in the “output” folder of auto-py-to-exe.