Python Plotly's Dash: How do you shut the web app running on a port or make changes to it? CTRL+C doesn't seem to be working - python-3.x

Am using Plotly's Dash and trying to run the sample app code which they have provided here: https://plot.ly/dash/getting-started#dash-app-layout
Am having trouble with the ports. The code on being run shows this in the console:
However , even after making changes to the code, the output in the web app shows no change.
Basically, when I'm implementing a different code: the web app continues to display the output from the previous run!
The CTRL+C doesn't seem to help and doesn't really quit or cause any change to the application. Please let me know what shall help.
I ran the new code using a new port(8049) and that worked but doesn't solve the initial basic issue!

I've had the same issues, and find that a full restart of the app is necessary to get some changes to propagate in the app after a file update.
In POSIX, you could run sudo killall python or similar. Looks like you're running Windows, so taskmanager or taskkill /F /IM python.exe.
The [1]: Looks like a Jupyter kernel is running? If so, try restarting the kernel.

For me CTRL+C doesn't work either, but CTRL+Pause/Break button stops execution.

Related

I am facing issues printing things on repl.it

I am new to repl.it and I was trying to print the python version using this code Print Version of the Python Running on the Machine
Here's the code:
import sys
print("Python version")
print (sys.version)
print("Version info.")
print (sys.version_info)
but it prints absolutely nothing. Trying to do the same thing onto Jupyter Notebook and my code works. While I know I can print the version directly from the shell tab out there but I was wondering what's wrong with my code and why it isn't working with repl.it
This seems to be the same for user input as well where I try to do
name = input("Print my name?\n")
but it prints absolutely nothing onto the console. I am sure someone here must know what am I missing here. Sorry if this is a noob question.
"Help! 🙋 My REPL won't run"
Here are six reasons your Python REPL.it environment may not be working. 📃
Checklist to fix common problems
Have you configured your Run ▶️?
Repl.it doesn't automatically run your current working document. Configuring your Run ▶️ button will enable replit to know what to do when you hit the button.
Configuring the "Run" Button
A file named .replit can be added to any repl in order to customize the behavior of the "Run" button. Written in toml, a .replit file looks something like:
run = "<run command here>"
language = "<repl language>" # optional
In the snippet above, run is a string which will be executed in the shell whenever you hit the "Run" button. The language helps the IDE understand how to provide features like packaging and code intelligence. This is normally configured for you when you clone from a Git repository.
The .replit file can also provide other configuration hints. The full specification is provided below:
run: Command that is executed when the run button is clicked
language: Reserved
onBoot: Command that is executed once when the repl first starts up
packager.afterInstall: Command that is executed after a new package is installed
packager.ignoredPaths: List of paths to ignore while attempting to guess packages (More about installing packages)
packager.ignoredPackages: List of modules to never attempt to guess a package for, when installing packages (More about installing packages)
Example .replit File
run="python main.py"
language="python3"
onBoot="echo Booting up!"
[packager]
afterInstall="date >> package_install_log"
ignoredPaths=[".git"]
ignoredPackages=["twitter", "discord"]
Attempt running the *.py script through the interactive shell instead of console. If the script runs in console, you may be needing to diagnose the shell. See choices below.
Check that the Browser Developer Console is not showing any errors If you see errors, you may be having issues with your browser or extensions. Try disabling browser extensions temporarily.
REPL.it relies on Google Cloud Platform services for its backend functionality and sometimes those servers are unresponsive. Check the REPL.it status page or the REPLIT Twitter account to see if they're having a GCP backend service outage. If they haven't updated recently, they may be responding to an unreported outage. Check Google's own GCP status page here. You can also Tweet at the CEO of Repl.it here.
Try refreshing the REPL.it environment locally. Clear the console output and scroll-back by using the ✖️ next to the search icon 🔍. Also, try exiting the Python REPL with exit() to see if it will respond.
If #5 doesn't work, try an empty-cache hard reload. This can help to expunge unresponsive javascript, broken html, misbehaving css, and any unmetabolized toxins from the bowels of your browser.

How to Save Images from A Program Ran from Ubuntu Application Start-up Command

We're trying to run a program at start with Ubuntu's Application Start-up command. We're successfully starting the camera and viewing the images. But the images are not saving to the folder we expect them to be saved too.
The program works flawlessly when started manually from the terminal. Saving into the appropriate folder.
Does anyone have any idea of how to get the images saved but when started from the Application Start-up command upon start-up?
Thanks.
You're not providing a whole lot of details, so my answer may be totally off. To me it sounds like you've created an app that takes a picture with the webcam and saves it to disk. Now you want the app run it when the user logs in, so you've added your app to the list of Startup Applications. The app starts, takes a picture, but can't write it do disk. If that's the case, I'd consider:
Try adding debug logging to your app, so you can see why it fails opening the file. What ever language this app is written in, if opening a file fails, the API will tell you. This information is vital. The easiest is to print to stdout and then, when starting the app, forward it to a log .e.g. /usr/local/bin/myapp &>> /tmp/myapp.log.
Try writing to a location like /tmp where permissions aren't that much of an issue.
Try adding a delay before starting the app, see this list of various approaches on how to do this, the most simple being using this a the command: sleep 10 ; /usr/local/bin/myapp &>> /tmp/myapp.log
If this is all rubbish you need to add more details in your question.

Can't kill NodeJS app

One day, out of nothing, my app decided not to die.
After pressing ctrl + c when I inspect port it's still there and not only on my machine but also on server that is managed by PM2 so I need to go there each time and kill the process by hand. I tried to look for issues in my code and when I couldn't I just though that it's simply one of the dependencies fault and soon there will be a fix. It was slightly annoying but I could kill the process with kill -9 PID and I had most of the tasks I had on front-end side so it wasn't that big issue. Today, more than a week later problem it's still here.
I went back in history, picked a commit that I made weeks ago, where everything worked perfectly fine, switched NodeJS from 5.1.0 to 4.2.1, cleared npm cache, reinstalled all dependencies and I still see the problem.
I'm using LoopbackJS, but normally I start the app simply with "node server/server.js" and then the problem described above happens, but if I use "slc run" and then try to kill the app with ctrl + c it just hangs forever, I mean I can press ctrl+c as many times as I want and it's still running in console foreground.
If instead of pressing ctrl+c I kill the tab in console, app dies without problems.
This is what I see after running "lsof -i tcp:4000" when the app is supposed to be dead but is not
Edit:
Running and killing it with Strongloop process manager - slc start/slc stop works fine but it would be more convenient to use normal way of running NodeJS app (node server.js) during development and it doesn't change the fact that there is some issue and it would be better to not hide it under the carpet.
Out of anger I stripped out my app to the most basic elements. File by file, piece by piece and I found the answer.
The culprit was phantomJS - https://github.com/sgentle/phantomjs-node. PATCH version 0.8.2 introduced this bug. Fix was created almost a month ago, merged a week ago but not published on npm yet.

How to execute a setup from an application to update it?

I'am currently writing an application that has to search on a web site if an update exists for this application. If it is the case the application download a setup file (created with inosetup) and then execute it.
My application is written in C++. And I do not arrive to do this process. I'am trying to call the setup using system(). If the command is system("mysetup") I cannot obtain what I want because the setup cannot replace the exe (currently running). So, I have tried to use system("cmd /C mysetup"), system("cmd/C start /min mysetup"), system ("cmd /C start /min /separate mysetup") without success. In these cases, the fact to stop the application also stop the setup. So I suppose that the setup is considered as a child process.
I have seen in some posts that it might be possible to use execcl(). But this function is in unistd.h. And this library is a little bit to specific for my needs (I need to be able to run on virtualized windows).
So do you have a way to do what I want?
Thanks for your help
OK,
A colleague to me gave me the solution. As we are using QT a QProcess::startDetached does exactly what I want.

What's the difference between an application launcher and type in an application name and run it from teriminal?

I have a QT application. When I use my created application launcher to start it, it doesn't work.
However, if I go to terminal and run the application from there, it works.
I'm wondering what their differences are.
Thanks.
Maybe your application launcher doesn't contain the right command and environment?
How is your launcher trying to start the program? Are any errors being reported?
It could be that the current directory is not set as expected. Or the command line parameters being sent aren't formatted correctly. Hard to say without seeing some code or an error message.

Resources