By default, all scripts in PyCharm seem to execute in a separate python interpreter called "Run", which, as far as I can make out, is pretty much independent of the IPython console running alongside. Now, to execute any snippet of the script after the whole thing has been run, I can copy-paste into the Run pane, but this is not ideal as it is not an actual python/ipython console. If I want to execute in the console, I will need to run the whole thing again inside the console (and not just a snippet) because the console doesn't seem to recognize/store any of the variables when it was run, which is tedious.
I've searched for a solution, but the closest I got was to enable "show command line afterwords" in the Run Configurations. This just seems to throw up an error on the lines of "file not found", which makes no sense. I'm running my script through SSH into a remote server, if that helps.
Go to run --> edit configurations...
towards the button you'll see a checkbox that says "run with python console"
make sure its checked
try to edit the run config, via run -> edit configuration.
And check the path of the working directory or the script directory.
Related
I'm currently working on a project with Electron 9.0.4 and Electron-Builder 22.8.0 and am faced with a problem that doesn't seem too difficult but there isn't a valid solution online! (At least I couldn't find it)
I have my main program that does all of the UI tasks, and a command line script that does some backend. The reason I have this command line script is so that I can run certain parts of the application without opening the window itself. Everything works fine on my computer. After running npm link, my CL script is added to my environment variables and I can just run it from the console. However, when I try to build with electron-builder, the problem occurs.
If I use my Setup.exe on another computer, the command line script just won't be added to the environment variables and I couldn't find instructions on how to do this in the electron, nodejs, or electron-builder documentation. What I found was a suggestion on another question to add npm -g install as a post-install script, but that had no effect either.
Someone else suggested adding npm link as a post-installation script, but firstly if I am not mistaken this function is not intended for production and secondly it created an infinite loop as npm link triggered the post-installation script over and over again.
Thats how the script is added to the project
"bin": {
"command-name": "/cl.js"
}
Any help is appreciated!
Since I couldn't find a direct solution to my problem and didn't want to look any further for a solution while being able to take a different approach.
I decided to take a step back and look for another method to solve my problem I came to the conclusion that I didn't really need to add a script to the command line. My solution was to look for a certain argument when starting the regular application.
if (process.argv.includes("cli")) { /* Do commandline stuff */ }
When the custom argument is found, I simply run the script that should've been run from the command line. Using this approach, you can create a shortcut to my executable that contains the custom argument and then instead of the application it runs the command line script.
I recently started used Atom IDE. It feels good. The only thing that I find difficult is to setup a project profile to run. In pycharm there is Run configuration, is there something similar to it in Atom ?
I have a project with multiple classes. When ever I want to run my script,I have to go to the main.py to launch 'ctrl + i'.
Could any one help me to setup the project in a such a way, when I execute 'ctrl + i' it automatically launch's main.py instead of the py file I am calling from.
In order to run a python script in tha Atom IDE, you can either press Ctrl+Shift+B or install a package called "terminal-tab" (https://atom.io/packages/terminal-tab). This package in an integrated command prompt like cmd on windows.
In the top bar, under "packages", go to "script", and select "configure script".
There put in the directory in which the program is, what command to run (python3 main.py), and select "save as profile." The window explains itself.
Then, you should be able to run from that profile with Alt+Ctrl+Shift+B, from whatever tab you're on.
Im new to python and pycharm and this is my first program when try to run the program i see that run and its configuration is disabled.
You have to run it first. Right click on the file name 1.py in the project folder at the left and select Run. Once you run it you will see the configuration.
I am not sure if this is a right place to ask this type of questions. I am a python beginner or programmer overall at this point. I am using Spyder to use python 3.6 (via Anaconda). I wrote a code that works fine when I run it in the current Ipython console. But I really need to run it in an external system terminal. In order to do so, I chose the following path: Run-> configuration per file -> execute in an external system terminal. That has been working fine. But now it refuses to work!
I validated that there is nothing wrong with my code by running something simple and saw that running via external system terminal does not work.
So far I deleted Anaconda and re-installed it. Could someone suggest what I should be looking for to diagnose the problem and fix it?
Thanks!
I had the same problem and noticed that unless the Working directory settings is set to "The directory of the file being executed", it won't work.
You can change it in "Run" > "Run configuration per file".
So I have a script that is launched on login via rc.local. The script calls a few other scripts to be launched and ran. However the console says that the file and/or directories could not be found. When I run the script manually after the login it works just fine. I have even tried to add a small delay so that I know that the system logged in. Any idea why this is and how to fix it?
Sorry if my answer is a bit vague but from what I understand is that the scripts require to be run via admin privileges. Let me elaborate, when the system starts it runs a set of specific scripts and this differs from distro to distro. Therefore, I'd check ~/.bashrc /etc/profile.dand most importantly ~/.bash_login. See what you can do there. Personally I added it here ~/.config/autostart worked fine. Don't forget to create a .desktop file.
Hope this helps