![]() |
Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. (/thread-9710.html) |
Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. - JGFMK - Apr-24-2018 I'm a relative newbie to Python. I'm running Python on a VM with Windows 2012 RC2 installed. I have Python 3.6.5 -x64 (from installer called python-3.6.5-amd64) I've installed SQLAlchemy 1.2.6. I'm just trying to run a simple script called 'sqlachemyver.py' with this in it: #!/usr/bin/env python3 import sqlalchemy sqlalchemy.__version__Per this link and this one regarding the shebang If I type python, it calls up the interpreter. I can copy/paste the code and it spews out '1.2.6' But I should be able to type 'python sqlachemyver.py' from the folder that contains the python, or 'sqlalchemy.py' However the '1.2.6' is not directed as output. If I type python sqlachemyver.py > out.txt, I get an empty file. I can't get scripts to generate output when I run directly from the cmd shell I'm also getting odd results in Visual Studio Code too (v1.22.2) when I try and run it: I followed the VS Code instructions here.Any pointers greatly appreciated. Thanks. Found answer myself... #!/usr/bin/env python import sys import sqlalchemy sys.stdout.write(sqlalchemy.__version__)Per here RE: Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. - nilamo - Apr-24-2018 (Apr-24-2018, 06:39 PM)JGFMK Wrote:#!/usr/bin/env python3 import sqlalchemy sqlalchemy.__version__ In an interactive session, the result of any expression is printed out for you, to make quickly typing easier. That's why you get output in the interactive prompt. Any other time, calling print("some value") is how you get output in the terminal.
RE: Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output. - JGFMK - Apr-24-2018 Right, so the version would be returned, just not output without print or the stdout.write. Thanks. |