A Python script runs fine if I start it manually in a command prompt (CMD
), e. g.
Script P:\theproject\thescript.py
:
import pymssql
if __name__ == "__main__":
files = open('test.txt','a')
files.write('this is a test')
Run manually:
C:\Users\theuser\AppData\Local\Programs\Python\Python39\python.exe P:\theproject\thescript.py
However, when double-click onto the file thescript.py
, the command prompt opens and closes immediately without any action having taken place, i. e. the file test.txt
is not written. This problem is similar to the general case. However, it seems to be due to the library pymssql
specifically. If I comment the first line (see below) and start with double-click, it runs fine, i. e. the file test.txt
is written.
#import pymssql
if __name__ == "__main__":
files = open('test.txt','a')
files.write('this is a test')
Why is there a problem with pymssql
being imported, and how can I make the script callable with double-click and pymssql
being imported?
I'm working with Windows 10 Pro and Python version 3.9.5.