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).
Related
I am veryy new in coding and wanted to get into it. So I downloaded VS code. But I tried to run a very simple python command and it does not let me. See the picture below.
Visual Studio code is not an IDE, it is a code editor, which means you cannot run nor debug code naturally, for that you would need to run it on the windows terminal, or install extra packages and dependencies. If youre new and just want to learn Python, i suggest starting with a python IDE like the standard one provided or something more advanced like Pycharm, and if you want to program on VsCode and in multiple languages, search some tutorials about how to compile and run code on the windows terminal.
Provide more details about how you installed python from Microsoft Store, from anaconda or via its official page https://www.python.org/downloads/. Try running
python --version
or
python3 --version
If so you can run a python file from terminal. Assuming my file is called test.py
python test.py
I am newbie with python and here is my problem. I installed python on my windows pc and as you can see on this picture, I checked it by the command python --version and it showed me the version, no problem.
But when I ran this very simple code:
my_text = "We made it!"
print(my_text)
It said to me that Python was not found! as you can see in the picture.
I searched on the internet, and add the path variable as they said in this guide:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
but it still does not run.
Could you please give me some advise on how to solve this?
Try using python to run your .py file, like this
python test.py
If you are seeing instructions that say to use python3 to run Python scripts, it's probably because the author of those instructions uses a system environment where python is used for Python 2 and python3 is used for Python 3.
In your case on Windows, Python 3 was almost certainly installed using python as the command to run, so you should use python and not python3 to run your scripts.
I am just getting started with Python and computer programming in general, so hopefully someone can help me out. I am trying to use PyQt4 to start learning how to code GUI's, and eventually use py2app to bundle these GUI's into Mac Applications...
The issue I am having is I just installed PyQt4 (or so I thought) on my computer, using MacPorts (http://www.pythonschool.net/pyqt/distributing-your-application-on-mac-os-x/). When following the guide, I did slightly modify the code I entered into terminal. At first, when I typed the sudo port install py33-pyqt4 command into Terminal, it returned
Error: Port py33-pyqt4 not found
So, I changed the command to sudo port install py35-pyqt4, which successfully installed python 3.5.2 along with PyQt4. When I type python3.5 into Terminal, Python3.5.2 loads, with PyQt4 working as well. I am able to import modules from PyQt4. Not sure if changing the command to install python 3.5.2 is what cause my issue.
The issue is this: I am unsure how to use IDLE (or another IDE, PyCharm for example) with python 3.5.2! I cannot find an IDLE version for python 3.5.2 on my computer. I do have python 3.5.1 and python 2.7 installed, along with their respective IDLE programs. PyQt4 modules, however, cannot be imported when I use these IDLE versions.
When I issued the sudo port install py35-pyqt4 command, did it install IDLE somewhere? Am I able to use PyCharm with python 3.5.2, if python 3.5.2 loads properly into Terminal? I just need some way to edit scripts outside of Terminal. Hopefully this is a clear enough question!
UPDATE:
I found the IDLE program... Realized that it was installed through MacPorts it is located in a MacPorts folder in my Applications folder. The only issue it that it will not open. Frustrating.
I also have IDLE programs which won't start. Not sure why.
If you are willing to use PyCharm, I would recommend that to you anyway. You can change the pythonpath in the PyCharm Settings -> Build, Execution, Deployment -> Console -> Python Console -> Python interpreter. Select here the appropriate Python binary.
If you are unsure about the pythonpath, type
which python3.5
in a terminal which should give you the path.
With that, PyCharm uses this Python version as your default.
I downloaded this tool to migrate MySQL to PostgreSQL: https://github.com/philipsoutham/py-mysql2pgsql
Python interactive code works properly so the python path is set in the right way.
When I type "py-mysql2pgsql" being in the directory: C:\Users\me, the downloaded tool doesn't run but ask me to choose the program to open that file. The same situation when I'm in C:\Users\me\py-mysql2pgsql
How can I run this tool properly?
Windows does not understand shebang lines in scripts (#!/usr/bin/env python) like Linux and Unix variants do. So Windows does not understand that this is a python script, you need to execute python yourself.
If python executable is in your path, you should be able to run:
python py-mysql2pgsql
If it is not in your path, you should be able to run:
path_to_python\python py-mysql2pgsql (on my machine C:\Python27\python)
Note that this applies to any python script on Windows, not just this tool.
I have a Python script and I'm trying to run it from Windows or some online Python interpreter. I would like my friend to test it but he doesn't have linux.
The conflict here is that I have modules such as "import os" in the script that is only native to the bash environment. So how can I get my friend to run my .py script in Windows?
Thanks!
The cool thing about python is that you friend should be able to run your script with little to no change(hopefully), to quote the python os docs
This module provides a portable way of using operating system
dependent functionality.
If your friend did have an issue you might have a another question to ask.