Configuring Python in Aptana to push output to console window - python

I have very recently been learning python. I have been using pyscripter as is demonstrated over on kahnacademy, but after finding some bugs in pyscripter decided to upgrade to a much more robust coding environ, hence aptana studio.
Right now I have python installed properly, it will run scripts, but I cannot seem to figure out how to get it to output print commands to the console window at the bottom.
To test this my script is simply:
print "hello"
The console gives me:
Finding files... done.
Importing test modules ... done.
---------------------------------
Ran 0 tests in 0.000s
OK
I know I am missing something really simple here but I haven't the foggiest what it could be.
I would like to see the python console output only - what could I be missing?

You're probably using the 'run unit-tests' launch instead of the regular launch. For a regular launch, just press F9 on the file you're editing and it should work. Also, if you still haven't, read the PyDev getting started guide: http://pydev.org/manual_101_root.html (or at least http://pydev.org/manual_101_run.html, which is the part related to your problem, and it'll also explain how to config Ctrl+F11 to relaunch your last launch, etc).

Aptana uses PyDev.
To run modules (.py) files in debug mode you need to tell the file what function you want to execute. Try this template when testing:
def main():
print "Hello world"
if __name__ == "__main__":
main()

Related

VIisual Studio Code using the wrong debugger (PLSQL Debugger) for my Python code

very basic one here. I wrote some Python code that worked fine, then used VS Code for SQL work.
Now I want to reuse Python and try as I might I can't get it to Run without first Debugging in PLSQL Debug. Even if I choose Run -> Run Without Debugging the terminal doesn't load the results of the Python script. Instead I get in the Debug Console:
"Debug started on port 4000, waiting on the client to connect..."
I am sure there is a straightforward answer to this, but how do I get back to VS Code treating my Python code like Python code? Thanks!
Your configurations have been changed when you first run PLSQL debug. Go to your main project path find the .vscode folder and delete launch.json.
After you deleted launch.json file, go to Run and Debug and start a new python debug mode
You can select the debug file type in Run and Debug.

python os.system("chcp 65001") does not work

Windows cmd does not handle utf8 well when executing print statements in python.
Many people said that we can type in "chcp 65001" before executing the python script in the cmd.
In our situation, we want to implement an app (in python pyc) with a desktop icon in Windows.
Thus our first solution is adding os.system("chcp 65001") to the source python script before the main function.
But somehow this did not work. Then some people said trying os.system("/k chcp 65001").
But this did not work either.
Our second soluiton is using a bat file with two lines, the first line is "chcp 65001" while the second is "python my.pyc" where my.pyc is main program of our app.
But this solution seems inconsistent since in some environment it failed while in others, it did not fail.
Moreover, with this solution, Windows does not allow us to change the logo (or icon image) of bat file.
Can someone help us solve this problem with cmd and utf8 with python scripts?

What does "== RESTART <path> ==" in the IDLE Shell mean?

I have a simple script I wrote, and when trying to run it (F5) , I get this msg:
================== RESTART: C:\Users\***\Desktop\tst.py ==================
I restarted the shell, reopened the script, but still, the same msg appears.
I use python 3.5.1 and I tried to simplify the script as much as possible, but I still get this result. Now my script is only one line with a simple print(1) command and I still get this msg.
Was there something wrong with the shell installation?
I have a simple script I wrote, and when trying to run it (F5)
That's the hotkey for IDLE to run a file. It is not ordering to do anything. It's a log statement to explicitly declare that your namespace is being cleared and the file is going to be ran fresh again.
no, I didn't tell it to restart
But you did... You pressed F5
The same thing is happening with my shell. In the older versions, this does not happen. I've also noticed that when I press Python 3.5.2 Module Docs, I have my Internet browser open up and I see my directory being displayed onscreen. It looks like:
C:\Users\mycomputername\AppData\Local\Programs\Python\Python35-32\DLLs.
Is that suppose to happen? Is that secured? I don't know.
I've also found that this prints out whenever I "imported" something. So if I use an import command, and put it right before the line of my random name, it will print out that "RESTART" thing. It's always at the beginning. Or what it reads as the beginning.
CIsForCookies, my guess is that you don't actually have a complete script; maybe you have just a function definition and you haven't included a line to run that function. (I had this problem and then remembered to call the function I defined; the problem went away.)
You may have made the same mistake as me and ran a program and then you wonder why RESTART is all that shows up. My program was working perfectly I just did not print anything or ask for any input so it ran and was done with the program and nothing showed up.

CEF3, Python -- nothing works when run from Eclipse, works from console

I just started trying out CEF3 (Chromium Embedded Framework) for Python and got it working -- but it only works when run from the console.
When I type "python ceftest.py" everything pops up nicely. When I hit ctrl-11 in Eclipse to run it, the window pops up but nothing is displayed. Minor annoyance as eventually this will be run from console, but in the mean time, for testing purposes, is there any way to have it work within Eclipse? Is this because I have different paths to modules in console vs eclipse? If so, how do I sync the two? Thanks.

Has PyDev an interactive shell (during debugging) as in Komodo?

so far I used the Komodo IDE for Python development, but I'm now testing Eclipse with PyDev. Everything works fine, but there is one Komodo feature that I'm missing.
In Komodo I can inspect the running application in a debugger shell. I.e. after hitting a breakpoint I can not only read the content of variables, but I can execute arbitrary Python code (e.g. changing the value of variables) and then continue program execution.
PyDev has also some interactive shell during debugging, but I can only read variables and not change their content. Is this feature not available in PyDev or am I missing something here?
Many thanks,
Axel
As you've seen, you can just use the console directly:
http://pydev.org/manual_adv_debug_console.html
Now, you can also connect the interactive console (which is a bit more advanced) by selecting a stack frame to attach it:
http://pydev.org/manual_adv_interactive_console.html
Yes you can do that. Just type in the console what ever commands you want :). I usually have to right click then
Debug As >> Python run
PyDev is a little bit quirky, but you get used to it.

Categories

Resources