Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Python with TCC Problems

  • Thread starter Thread starter Bob
  • Start date Start date
Aug
28
2
It's probably an artifact of my ignorance but I'm having problems trying to use and understand TCC support for Python. :confused:
TCC 33.00.20 x64 Windows 11 [Version 10.0.26100.2605]
$which python
python is an external : C:\Program Files\Python313\python.exe
$python --version
Python 3.13.1
The example in TCC Help and a naive attempt to use @Python give the following results:
$echo %@python[print("Printing from Python")]
0

$echo %@python[2 + 2]
0
For a simple Python installation sanity check I then tried running a classic Python program.
Python:
# Hello World in Python
print("Hello World!")
with the following result:
$python Hello_World.py
Hello World!
Then I checked to see if a Python program with a .py extension would be detected by TCC and passed to the Python interpreter for execution:
$Hello_World.py
and got the following result:
Faulting application name: tcc.exe, version: 33.0.20.0, time stamp: 0x6750e007
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000409
Fault offset: 0x00007ffd592a328f
Faulting process id: 0x4F7C
Faulting application start time: 0x1DB611EF5ABB9DD
Faulting application path: C:\Program Files\JPSoft\TCMD33\tcc.exe
Faulting module path: unknown
Report Id: 6753a96f-4b2f-4292-863a-e4d436df0168
Faulting package full name:
Faulting package-relative application ID:
FWIW I get the same results on Windows 10.

I would greatly appreciate any explanation of my mistakes(?) or tips on how to successfully use Python with TCC.
TIA :smile:
 
On v34, running the example from the help file...
Code:
R:\>which /a @python
@python is an internal variable

R:\>echo %@python[print("Printing from Python")]
TCC: Could not load Python dll

Joe
 
Here it loads the DLL and @PYTHON does nothing.

Code:
d:\python> listdlls %_pid | grep pyt
0x0000000076a70000  0x64e000  D:\python\python313.dll

d:\python> echo %@python[print("Printing from Python")]
0
 
From the help file...
The Python language is not built into TCC, and must be obtained separately. The version supported by TCC is from https://python.org. TCC supports versions 3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 2.7, 2.6, and 2.5. (TCC will search for the Python dll's in that order.)

You must enable Python support in the OPTION / Startup page. If it is enabled, TCC will automatically load a Python interpreter when it starts. If a suitable library is found, TCC checks to see if you are running a .PY file. If so, TCC passes the file to your Python interpreter for processing.

That explains why it does not work on my system,
as I use the Python from the Microsoft Store.
Code:
R:\>which python 
python is an external : C:\Users\jlcav\AppData\Local\Microsoft\WindowsApps\python.exe

Joe
 
I do have python installed (from python.org) and it works here:

Code:
TCC  34.00.13 x64   Windows 11 [Version 10.0.26100.2605]

D:\Users\Michael\OneDrive>echo %@Python[print("Hi there")]
Hi there
0
 
@Fross

That's not the problem. It's successful here too. The problem is a python script with .py (if python is enabled (see above)).

Try the following:
 

Attachments

Last edited:
Thanks @Alpengreis

That seemed to work for me:
Code:
D:\Users\Michael\OneDrive\Desktop>testpython.py
Hello World!

I do have an executable extension setup in my tcstart.btm and python is in my path
Code:
set .py=Python.exe
 
@Fross

Ah, ok - that's interesting - thank you for info. I believe without that extension setup and with enabled option for python it would be crash too on your side.

However: good to know.
 
I just installed Python today. This is odd. Does anyone else have it?

Code:
t:\> assoc .py
.py=Python.File

t:\> ftype python.file
python.file="C:\Users\vefatica\AppData\Local\Programs\Python\Launcher\py.exe" "%L" %*
 
It's crashing for me too. And I still get nothing from @PYTHON.
 
@vefatica

Yes, Vince, you are right - the @PYTHON is also empty here with examples above.
 
It's working as expected here.

Is Python313.dll (or whichever version you're using) in your PATH?

Are you using the x64 version of Python? (The x86 version will not work with TCC, which is 64-bit.)

The @python[2 +2] example in the help is obsolete; python changed how the results are displayed. However, the %@python[print("Printing from Python")] example should work (and does here).

There is a difference in running a .py script depending on whether you have the Python option checked in OPTION / Startup / Scripting. If it isn't checked, TCC is passing the script name to Windows to find an association for .py and to execute it. If the option is checked, TCC is running the script in the Python dll inside the TCC session, so you can pass variables back & forth.
 
@rconn

Tested in Beta 34.00.13 - same problems:

  • Execute a .py script crashes IF option for python is set. Else it's ok (of course).
  • echo %@python[print("Printing from Python")] does nothing

Python 3.13.1 64-bit in path.
 
Then I hope, it's ok for me too in build 14 ... will test it of course.

BTW: I had that problem also in older version ... MUCH MUCH older versions I believe ... then I lost the focus about that.
 
[Can you do anything about copying from the help? Copy only what's selected would be great.]

The help says

<style type="text/css">    div#pagewrapper {display: none;}    div#fouc {display: none;}    div#noscript {        display: block;        position: absolute;        top: 0; right: 0; bottom: 0; left: 0;        border: 1rem solid grey;        background-color: #eaeaea;        }    h2#noscriptwarning {        text-align: center;        position: relative;        top: 35%;        color: #333333;    }    </style>    

If it is enabled, TCC will automatically load a Python interpreter when it starts.[/code]

That doesn't seem to be the case. I don't know about running a .PY (TCC crashes) but the DLL isn't loaded until I use @PYTHON (which fails to produce output) the first time.
 
Copying from the help works fine here (that may be an issue with your browser):

The Python language is not built into TCC, and must be obtained separately. The version supported by TCC is from https://python.org. TCC supports versions 3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 2.7, 2.6, and 2.5. (TCC will search for the Python dll's in that order.)

You must enable Python support in the OPTION / Startup page. If it is enabled, TCC will automatically load a Python interpreter when it starts. If a suitable library is found, TCC checks to see if you are running a .PY file. If so, TCC passes the file to your Python interpreter for processing.
 
I have exatcly this python version from python.org (64-bit), NOT the MS Store version and I have enabled the option for Python scripting ...
 
Copying from the help works fine here (that may be an issue with your browser):

The Python language is not built into TCC, and must be obtained separately. The version supported by TCC is from https://python.org. TCC supports versions 3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 2.7, 2.6, and 2.5. (TCC will search for the Python dll's in that order.)

You must enable Python support in the OPTION / Startup page. If it is enabled, TCC will automatically load a Python interpreter when it starts. If a suitable library is found, TCC checks to see if you are running a .PY file. If so, TCC passes the file to your Python interpreter for processing.
Yes, Python is enabled. It's not loading the DLL at startup. It's loading it when I use @PYTHON.

Please try this.

In the help, select precisely the blue stuff below and right-click\copy:

1736458114118.webp


Paste it into a new forum post and immediately choose "Preview".

When I do that, before choosing Preview, I see this.

1736458472690.webp

After choosing Preview I see this

1736458559901.webp
 
Yes, Vince is right, I have exactly the same problem with copy and preview.
 
rconn said:
Is Python313.dll (or whichever version you're using) in your PATH?
The path elements referencing Python follow:
$path /n
C:\Program Files\Python313\Scripts\
C:\Program Files\Python313\
. . . . . . . . . . . .
. . . . . . . . . . . .
rconn said:
Are you using the x64 version of Python?
The x64 version according to sigcheck see following:
$which python
python is an external : C:\Program Files\Python313\python.exe
$sigcheck64 -nobanner "c:\Program Files\Python313\python.exe"
c:\program files\python313\python.exe:
Verified: Signed
Signing date: 2:13 PM 12/3/2024
Publisher: Python Software Foundation
Company: Python Software Foundation
Description: Python
Product: Python
Prod version: 3.13.1
File version: 3.13.1
MachineType: 64-bit
rconn said:
There is a difference in running a .py script depending on whether you have the Python option checked in OPTION / Startup / Scripting.
The Python option is checked.
$option Python
Python=Yes

Thanks for taking the time from v34 to respond. Let me know if I can provide any further information. :smile:
 
Last edited:
Wow - build 14 fixes both problems with Python:

So, when python script option is enabled:

Code:
echo %@python[print("Printing from Python")]
Printing from Python
0
is working now!

And executing a .py script ...
Code:
type testpython.py
# Hello World in Python
print("Hello World!")

testpython.py
Hello World!
... works now too!

Thanks very much!
 
Back
Top