Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Simple solutions for the oserror: [winerror 193] %1 is not a valid win32 application error
Next
Answered
Lou Sanchez
  • 27
Lou Sanchez
Asked: May 12, 20222022-05-12T10:09:20+00:00 2022-05-12T10:09:20+00:00In: python

Simple solutions for the oserror: [winerror 193] %1 is not a valid win32 application error

  • 27

. Advertisement .

..3..

. Advertisement .

..4..

I get an error

import subprocess 
 subprocess.call(['hello.py', 'htmlfilename.htm'])
 Traceback (most recent call last):
  File "<pyshell#42>", line 1, in <module>
  subprocess.call(['hello.py', 'htmlfilename.htm'])
  File "C:\Python34\lib\subprocess.py", line 537, in call
  with Popen(*popenargs, **kwargs) as p:
  File "C:\Python34\lib\subprocess.py", line 858, in __init__
  restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
  startupinfo)
 OSError: [WinError 193] %1 is not a valid Win32 application

when trying to call a Python file “hello.py” from within the python interpreter with subprocess. How to fix the oserror: [winerror 193] %1 is not a valid win32 application error? Please give me some advice.

 

It is quite obvious. The hello.py file is not executable. The executable must be specified:

subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])

To make python.exe visible in the search path, you can either pass the entire path to the executable that runs the calling script or the python.exe address.

import sys
subprocess.call([sys.executable, 'hello.py', 'htmlfilename.htm'])
oserror
  • 2 2 Answers
  • 325 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dhtutoria Expert
    2022-06-02T00:17:33+00:00Added an answer on June 2, 2022 at 12:17 am

    The cause: This error happens because  the file hello.py  is not an executable file. then you have to specify the executable:

    subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])

    The solution: To resolve this error you’ll need python.exe to be in the search path, or you can specify the entire path to the executable file running the calling script:

    import sys subprocess.call([sys.executable, 'hello.py', 'htmlfilename.htm'])
    • 11
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Nathan Gras
    2022-05-25T19:41:27+00:00Added an answer on May 25, 2022 at 7:41 pm

    Installers of Python usually register.py files to the system. It works if you explicitly run the shell

    import subprocess
    subprocess.call(['hello.py', 'htmlfilename.htm'], shell=True)
    # --- or ----
    subprocess.call('hello.py htmlfilename.htm', shell=True)

    On the command line, you can inspect your file associations.

    C:\>assoc .py
    .py=Python.File
    
    C:\>ftype Python.File
    Python.File="C:\Python27\python.exe" "%1" %*
    • 14
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.