質問

I am just learning python as my first programming language, and I just installed python 3.3, 64 bit on my windows 7 OS.

I installed komodo edit 8.0, and I am trying to print ('Hello world'). I set up the correct path so that I can access python through my command prompt.

From komodo, I saved my helloworld.py file to my desktop.

When I try to run the command prompt, I search for the file, and it says file not found, or file does not exist. I can open the folder from komodo, but it appears that it is empty. When I open the folder directly from my desktop, I see the file is in there, so it seems that komodo is not recognizing it.

How can I get Komodo to recognize my saved file and run it in python? I am very new so please go step by step if you can.

Thank you!

役に立ちましたか?

解決

Many of the comments you've received recommend avoiding Komodo IDE. But you're not using Komodo IDE! You are using Komodo Edit, so the comments about IDEs just don't apply.

Sure, you could use Notepad++ or even plain old Notepad, but neither of those offers any real benefit over Komodo Edit. In fact, you would be losing a valuable feature of Komodo (both IDE and Edit version): realtime syntax checking.

I use Komodo IDE and like it quite a lot. If you want to run Python programs inside Komodo and debug them right there, Komodo IDE is a great choice.

One problem may be simply that you're expecting Komodo Edit to offer the same features as Komodo IDE. It doesn't. It's just a very nice editor. You need to run your Python code outside Komodo using the command line or other means. Just open a command prompt, cd to your directory, and type python yourfilename.py.

But you say you already tried that? It must be simply a matter of being in the wrong directory.

If you have your .py file open in Komodo, do a Ctrl+O right there, and the Open File dialog will show you the file's path at the top of the dialog. You can use Alt+D to select the path, and from there you can copy it and paste it into the command line if you need to cd to that directory.

If you'd like to use an interactive debugger (an excellent idea!) without paying for Komodo IDE, you can use PythonWin.

Install Mark Hammond's Python for Windows extensions. Included in this package is PythonWin. You can open your .py file in PythonWin and select File/Debug/Step In to start debugging your code. Then you can use the other commands on the File/Debug menu to step through it. Take note of the F10/F11/etc. keyboard shortcuts which give quicker access to these commands.

Whichever way you do it, I highly recommend using an interactive debugger like this when learning a new language. Being able to stop the code and look at your variables right then and there is a huge improvement over being limited to print statements for debugging.

So I disagree quite strongly with the recommendations against using an IDE like Komodo. The very first thing I look for when I learn a new programming language is an interactive visual debugger. I don't care too much whether that debugger comes packaged as part of an "IDE" or is a standalone debugger, as long as it shows the source code, makes it easy to single step, and shows the variables whenever it's paused.

他のヒント

Ok heres what I personally do.

  1. Open run, type in cmd

  2. Navigate to whatever directory my mypythonfile.py file is

  3. Open whatever text editor you feel like ( personally i use notepad++ because it is NOT an IDE like kodomo, but just a pretty text editor.)

  4. Type python mypythonfile.py and hit enter. This will run the program.

  5. Open mypythonfile.py in text editor program.

  6. Make changes to the python file.

  7. Go back to the cmd window and press arrow up ( to go to the last typed command) and then press enter again, to run the program again.

Repeat steps 6-7 until your program is perfect.

It seems like you are having trouble with the Kodomo IDE instead of the actual learning python process. IDEs are complicated tools with lots of buttons that are scary. Learn the language first, then once you are comfortable there, then maybe you will use an IDE? Or maybe you will just keep using a text editor instead. Thats up to you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top