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 a question.

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

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:02:50+00:00 2026-06-02T07:02:50+00:00

I have a test script, e.g. test.py, and I want to make it so

  • 0

I have a test script, e.g. “test.py”, and I want to make it so that it executes with a particular environment variable set before the script begins:

#!/usr/bin/env TEST=anything python

print "Hello, world."

Running this normally works as expected:

$ python test.py 
Hello, world.

However, if I run it as a program:

$ chmod +x test.py
$ ./test.py 

The string is never printed, instead the execution just stalls and “top” reports a process called “test.py” which is using 100% CPU.

This only happens on my Ubuntu machine, seems to be fine on OS X.

The reason is that eventually I want to make a particular script always run in a 32-bit Python by setting:

#!/usr/bin/env VERSIONER_PYTHON_PREFER_32_BIT=yes python

at the top of the file. However this is a no-go if it means the script won’t execute on Linux machines. I found there is a similar effect no matter what the specified environment variable is called. However, if there is no environment variable set:

#!/usr/bin/env python

print "Hello, world."

The script runs just fine:

$ ./test.py 
Hello, world.

Is this a bug in Python or in env, or am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:02:51+00:00Added an answer on June 2, 2026 at 7:02 am

    On Linux,

    #!/usr/bin/env TEST=anything python
    

    passes TEST=anything python as one argument to env.
    So env will not process the argument properly.

    The bottom line is you can only put one command after env on the shebang line, all else will at best be ignored.

    From the Wikipedia entry on Shebang:

    Another portability problem is the interpretation of the command
    arguments. Some systems, including Linux, do not split up the
    arguments[24]
    ; for example, when running the script with the first
    line like,

    #!/usr/bin/env python -c

    That is, python -c will be passed as one argument to /usr/bin/env,
    rather than two arguments. Cygwin also behaves this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple test bash script which looks like that: #!/bin/bash cmd=rsync -rv
I have the following simple python test script that uses Suds to call a
I have a python script: main.py , which executes a cx_frozen python script: test.exe
I have a script that works fine on my test server (using IIS6). The
so i have ruby script that simply writes to a test.txt file with hello
I want to make a simple HTTPRequest to a php script and I have
I have a number of tables that together make up a Test that somebody
I have a collection of examples that I want to make sure they fail
I have created a script to run a test script on a batch of
I have a test suite to perform smoke tests. I have all my script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.