logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: How to configure environment variables?
Author
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Mon 26 Jun '23 3:10    Post subject: How to configure environment variables? Reply with quote

Hey guys,

I have Python running as CGI, every file .py has a first line that reads:

Code:
#!/C:\program files\python311\bin\python3.exe


But When I try to run files from Linux they fail because the first line on them is:

Code:
#!/usr/bin/python3


And Windows cannot find it, so I'm looking for a way for Windows to interpret the Linux line for the windows line.

How can I do that?

Thanks.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7298
Location: Germany, Next to Hamburg

PostPosted: Mon 26 Jun '23 11:38    Post subject: Reply with quote

Install your Python on Windows into C:\usr instead of C:\program files\python311

But you could also use ScriptInterpreterSource[1]


Here is what an exported key looks like:

Code:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.py\Shell\ExecCGI\Command]
@="c:\\program files\\python311\\bin\\python3.exe"


Also, make sure to have that enabled in your document root

e,g,
Code:

<VirtualHost *:80>
   <Directory "/Users/you/work">
      <Files ~ "\.py$">
         Options Indexes ExecCGI
         AddHandler cgi-script .py
      </Files>
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
   </Directory>
</VirtualHost>


[1] https://httpd.apache.org/docs/2.4/en/mod/core.html#scriptinterpretersource
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Mon 26 Jun '23 20:18    Post subject: Reply with quote

Thank you, I will give it a try.
Back to top


Reply to topic   Topic: How to configure environment variables? View previous topic :: View next topic
Post new topic   Forum Index -> Apache