Python Forum
Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python on Windows 2012RC2 (with VS Code 1.22.2). Scripts not generating output.
#1
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:
Output:
C:\opt\tidalconversion>cd c:\opt\tidalconversion && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:\opt\python\3.6.5-x64\python.exe C:\Users\administrator\.vscode\extensions\ms-python.python-2018.3.1\pythonFiles\PythonTools\visualstudio_py_launcher.py c:\opt\tidalconversion 61892 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput c:\opt\tidalconversion\sqlalchemyver.py "
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
Reply
#2
(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.
Reply
#3
Right, so the version would be returned, just not output without print or the stdout.write. Thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to communicate between scripts in python via shared file? daiboonchu 4 1,438 Dec-31-2024, 01:56 PM
Last Post: Pedroski55
  Windows Disk Cleanup Code Help Needed nal2us2 3 1,005 Jul-19-2024, 04:03 AM
Last Post: deanhystad
  Trying to generating multiple json files using python script dzgn989 4 2,066 May-10-2024, 03:09 PM
Last Post: deanhystad
  problem in output of a snippet code akbarza 2 1,183 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  Trying to us python.exe from our network to run scripts cubangt 3 1,889 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 3,118 Mar-27-2023, 07:38 AM
Last Post: buran
  I cannot able to see output of this code ted 1 1,308 Feb-22-2023, 09:43 PM
Last Post: deanhystad
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 2,066 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  why I dont get any output from this code William369 2 1,764 Jun-23-2022, 09:18 PM
Last Post: William369
  How can I organize my code according to output that I want ilknurg 1 1,745 Mar-11-2022, 09:24 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020