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 8633429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:29:20+00:00 2026-06-12T09:29:20+00:00

To make a Python script executable on Linux and bash, one uses the shebang

  • 0

To make a Python script executable on Linux and bash, one uses the shebang

#! /usr/bin/env python

as the first line of the script. If this line happens to end with the Windows-style newline \r\n (carriage return – line feed), instead of the Unix-style newline \n, then bash will not be able to run the script through the Python interpreter.

I am doing cross-platform development in Python. When I work in Windows, the natural newline is \r\n. When I work in Linux, the natural newline is \n. Given that I use Mercurial for version control, what would be the best way to enforce the use of the \n newline in the script file containing the shebang?

  • 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-12T09:29:21+00:00Added an answer on June 12, 2026 at 9:29 am

    The common approach is not to generate the outer wrapper scripts yourself at all, but specify them in your setup.py and let them be generated during package installation.

    If you do something like the following:

    setup(
        entry_points = {
            "console_scripts": [
                "script_name": "your.module.name:main",
            ],
        }
    )
    

    …then, on installation, a wrapper named script_name will be generated and installed, and configured appropriately to run on your current platform (shebang line and all). This makes the end-of-line characters in use moot.

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

Sidebar

Related Questions

I was wondering how to make a python script portable to both linux and
I am trying to make a python script executable with the setuid bit set.
How do I make an executable from Python 2.7.3 scripts? This seems to work
Possible Duplicate: How to make python scripts executable on Windows? Set up Python on
I'm trying to make a small Python script that is executed by clicking an
I'm trying to make a python binding for the this library: http://code.google.com/p/hosterslib/ . I'm
I have a Python script and I was wondering how I can make it
I'm trying to make a Python script run another program from its own path.
I'm trying to make my Python script stream its output to my webpage as
I have a python script which calles a bash script. The bash script compiles

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.