Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Python2.7 on cPanel Error message

Discussion in 'General Discussion' started by Vasanthjan, Aug 28, 2017.

Tags:
  1. Vasanthjan

    Vasanthjan Member

    Joined:
    Mar 8, 2017
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    I have followed the below link. It is working inside the cgi-bin folder, not in public_html.

    Short Guide to Running Python Scripts with cPanel

    Instead of getting error:

    /usr/bin/python2.7: can't open file '\r' [Errno 2] No such file or directory: /home/username/public_html/2numbers.py

    Can any one help me
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you let us know the entries you've added to the .htaccess file in the public_html directory, and verify that you copied the .py file to that location?

    Thank you.
     
  3. Vasanthjan

    Vasanthjan Member

    Joined:
    Mar 8, 2017
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    .htaccess file entries

    Options +ExecCGI
    AddHandler cgi-script .py

    File permission for 2numbers.py -> 0755

    Website Link: domain.tld/2numbers.py

    I can't get this point Michael: verify that you copied the .py file to that location?
     
    #3 Vasanthjan, Aug 28, 2017
    Last edited by a moderator: Aug 28, 2017
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    For instance, did you copy the "2numbers.py" file from your cgi-bin to your public_html directory?

    Thank you.
     
  5. Vasanthjan

    Vasanthjan Member

    Joined:
    Mar 8, 2017
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Both are different code Michael

    #!/usr/bin/python2.7

    import time
    import datetime
    print("Current date and time: " , datetime.datetime.now())
    print("Current year: ", datetime.date.today().strftime("%Y"))
    print("Month of year: ", datetime.date.today().strftime("%B"))
    print("Week number of the year: ", datetime.date.today().strftime("%W"))
    print("Weekday of the week: ", datetime.date.today().strftime("%w"))
    print("Day of year: ", datetime.date.today().strftime("%j"))
    print("Day of the month : ", datetime.date.today().strftime("%d"))
    print("Day of week: ", datetime.date.today().strftime("%A"))

    the above code is used on 2numbers.py

    code which is used on cgi-bin just a print statement.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,220
    Likes Received:
    1,376
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Feel free to open a support ticket using the link in my signature so we can take a closer look.

    Thank you.
     
Loading...

Share This Page