I am using atom editor. I installed atom runner for run to my programs but i have encountered too many problems. I want to run pyfiles in cmd console automaticly. How can i do this
In a nutshell:
How can i run py files in cmd console with shortcut
I am using windows
This is honestly not related to stack overflow since this isn't exactly a computer programming question. More of an operating system question. However, I believe you can install bash (linux command line) on windows and this would help solve your problem. Here is a link:
https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10
OR if you prefer using the windows command line, this link can explain how to run python (although i'd recommend using bash and not cmd):
http://www.cs.bu.edu/courses/cs108/guides/runpython.html
I suggest you install the "Script" extension and then run Atom using cmnd-I in the editor. Your file runs in the terminal.
Related
It's my first post on this web site. I'm having a problem with running my python codes on Windows Power Shell although my Atom text editor can run. Because I've alread installed the latest python version. When I try to run codes with PowerShell it says me basicly that Python can not be found.
Do you have any idea to solve this problem.
Thank you.
Find python (where /R \ python.exe) and add it to your path (win+r systempropertiesadvanced, go to environment variables, find PATH under the top box, start editing it, then add the python.exe directory to path.) Then restart powershell.
I have this file.py:
import os
os.system("pip install pip")
os.system("pip install selenium")
How do I make it work for MAC and what is te equivallent of a .bat file in MAC to execute the file.py.
Your file.py script will generally work fine on Mac as long as the environment the script is running in is set up right. Most notably, the pip executable has to be findable via the current PATH variable. You might benefit by looking at the subprocess module, which is an alternative API for running external commands. It is a more robust mechanism for doing so.
The equivalent of a .BAT file is a shell script. You have a choice as to which shell to use to run the script. I think the most common source is the Bash shell. It is often the case that you use whatever shell is running at your command prompt. This functionality is generally much more general and flexible than a .BAT file is on Window. See this link for a discussion of many of the issues:
https://developer.apple.com/library/archive/documentation/OpenSource/Conceptual/ShellScripting/shell_scripts/shell_scripts.html
A shell script can just be one or more commands that you might run in your Terminal. For example, to run test.py at a Terminal prompt, you'd do this:
> python test.py
The simplest equivalent in a shell script would be the same thing:
python test.py
A script that looks like this is run by whatever shell executes the shell script. What is more usually done is that a "shebang" line is added to the top of the shell script to explicitly define which shell will be used to run the script. So what the single line script above should really look like is this:
#!/bin/sh
python test.py
This may be starting to make your head spin. I would suggest reviewing the link I gave above, and possibly reviewing some other materials that explain shell scripts. Note that nothing about shell scripts is unique to the Mac. The concept is exactly the same on Linux, Unix, etc.
BTW, do you really want pip install pip? What does that do? Doesn't the pip package have to already be installed if the pip command is working?
I would like to know if there is a way to run python scripts in spyder-ide using windows cmd or PowerShell instead of IPython console.
Ipython sometimes works differently than if the script is run in cmd specially for plotting packages like matplotlib, etc.
I am using Spyder latest version.
Regards
In Spyder, you can click Run > Configuration per file, which will give you plenty of options in where your Spyder-IDE-Script is launched.
I think the option you are looking for is "Execute in External System Terminal" in the options found under the menu item of [Tools] / [Preferences] / [Run]
I'm making Python software using wx GUI library but was wondering how to run this script on different OS's. For example, do I need to create executable installation file or bat file on Windows and sh file in Ubuntu?
I've got #!/usr/bin/env python at the top of the file and I can seem to run it by actually double clicking it and clicking it on "RUN" on prompt window but I would like it to be more professional as the users are not programmers.
Being used to run python scripts on both linux and Windows environments, I know that you can use the same script for both environments.
Keep using your shebang in Linux, it won't be procesed in windows (as it is actually a comment :).
Once Python is installed in Windows, you can actually simply double click on the script (it will run by default in a cmd window), run it using the cmd or launch it in idle.
If you want to develop python scripts on windows however, you'll need some more tools :).
If you want to be more professional (and prevent your users to modify the code :), you can still think about creating an exe file : http://www.lyxia.org/blog/developpement/python/creez-des-executables-46
(warning, french inside), by using pyinstaller http://www.pyinstaller.org/ . Works for windows and linux
Can anyone please tell me an IDE for running python programs? Is it possible to run the program through command line?
Take a look at ActiveState's ActivePython. It's quite a nice implementation of Python on Windows. Another way is using Cygwin's Python port. These two are Python implementations. I don't use an IDE, I write my Python code in Notepad++.
To run a python program after saving it to C:\Users\vaibhav\Code\myscript.py:
ActivePython: If I remember right, ActiveState updates the path correctly. So it should be a s simple as:
Press "start" in the task bar
In the search field search for "cmd"
In the appearing box navigate to your folder with the python script: dir Users\vaibhav\Code
call python myscript.py and you're done
Cygwin: After installing Cygwin, you have a full-featured bash terminal on your Windows machine.
click on the Cygwin icon on your desktop
In the appearing window navigate to the folder with your python script: cd /cygdrive/c/Users/vaibhav/Code
type python myscript.py
e voila
IDE for running scripts? You can have any IDE you like, but if you need only to run python scripts you go like this:
python.exe pythonScript.py
I like the EasyEclipse for python distribution. You'd need to have python and java installed of course.
PyDev and Komodo Edit are 2 nice Python IDE on Windows.
I also like the SciTE text editor very much.
These 3 solutions make possible to run Python scripts
I tried to run a Python script with multiprocessing on windows. see this tutorial
It does not work on Windows, but on raspian it went very well. Thus I knew that it was a Windows problem. I installed cygwin and followed this tutorial Installing Python inside Cygwin.
After that I additionally installed numpy with the command easy_install numpy and now i can run python scripts with multiprocessing on windows (from cygwin).