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]
Related
I have both anaconda and VS Code installed in my system. When I start writing a script, VS Code gives me an option to chose the interpreter. I choose my particular conda environment. This works fine. However when I try to run the script using Ctrl+Alt+N or using the play button on the top right (using the extension Code Runner), the terminal that opens in the VS Code doesn't recognize that I am now working in a conda environment.
As a result, it gives an error that the module is not installed (because the module is available only in the conda environment).
When I try to manually activate the conda environment from the VS Code terminal, it doesn't work.
What is the workaround? I am using Windows.
Update: If I use cmd as the default integrated terminal in VS Code in place of PowerShell, then the command activate NAME_OF_ANACONDA_ENV works. And then, I can manually run the script. However, running the script using Ctrl+Alt+N still doesn't work; it doesn't recognize that I am in a conda env.
After a few tries i figured out how to do it. So, this works for me.
vs code settings search: code-runner.executorMap
Choose User and
Edit in settings.json
find: "python": "python -u"
change: "python": "$pythonPath -u $fullFileName"
if you encounter tempCodeRunnerFile or selection problem:
vs code settings search: code-runner.ignoreSelection
tick the box
On windows 10: Ctrl+Shift+P and selecting the environment gets the job done.
After setting the environment, I execute by pressing Crtl+F5 to execute without debugging and F5 to debug.
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.
I started a new project in PyCharm. I have Anaconda 3.6 installed. So, in PyCharm, I selected the Anaconda python.exe as project interpreter.
When I first ran PyCharm, it used the IPython console as "default" console to run my script. Then I restarted my PC and now PyCharm uses the terminal when I run my scripts. Why? I don't want to use the terminal, coming from Anaconda Spyder IDE. I'm used to IPython, I like it and I want to use it.
How can I completely disable the terminal and use only the IPython console?
Short answer:
Go to File > Default settings > Build, Execution, Deployment > Console and select Use Ipython if available
Go to Run > Edit Configurations and select Show command line afterwards
Tip: Run selected parts of your code with ALT + SHIFT + E
The details:
If you've selected Anaconda as the project interpreter, IPython will most likely be the selected console even though it neither looks nor behaves like the IPython console you are used to in Spyder:
Unlike Spyder, PyCharm has no graphical indicator showing that this is an IPython console.
To make sure it's an IPython console and make it behave more or less like the IPython console you are used to from Spyder, you should follow these two steps:
Go to File > Default Settings > Build, Execution, Deployment > Console and make sure to select Use IPython if available.
Go to Run > Edit Configurations and select Show command line afterwards
Now you can run selected parts of your code with ALT+SHIFT+E more or less exactly like in Spyder.
If this doesn't do the trick, you should check out these other posts on SO:
Interacting with program after execution
Disable ipython console in pycharm
In the new version of Pycharm, you have a different option in Edit Configuration.
Go to Run > Edit Configurations and select Run with Python console
On my mac I am trying to make a Python script open by default in the Python Launcher.
I left click on the script and select "open with" and select the Launcher. Every-time I do this Terminal pops up, the Launcher window appears briefly. Then a messages pops up in a window: "Python Launcher can only run certain scripts try another."
Something along those line (the message has stop popping up since the first time I tried it but the script still doesn't run). I tried everything, GUIs, and basic scripts (like print "Hello World"). None work!
I tried doing the same thing on other computer and I get the same problem. What am I doing wrong ?
Does your script use a shebang line:
#!/path/to/executable/python2.6
And does it have execute permissions?
chmod +x path_to_file.py
It should run OK like this.
Assuming you're talking about Anaconda, Launcher is now deprecated, so your approach will have to change anyway. It has been replaced by Navigator.
Make sure you have updated Anaconda within terminal using
conda update conda
Then, you can install Navigator with
conda install anaconda-navigator
You will see a new icon show up that functions much the way Launcher used to. Your script will now have to be tied to it instead of launcher, assuming you figured that out with previous commenters' help.
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).