Results 1 to 4 of 4

Thread: Python running Perl instead of Python?

  1. #1
    Join Date
    Dec 2015
    Location
    /home/
    Beans
    22
    Distro
    Ubuntu 17.04 Zesty Zapus

    Python running Perl instead of Python?

    So I have a Python file (test.py to be specific), and if I have the code:

    Code:
    print "Hallo"
    Save it, open file browser and double click it (yes, I allowed it to be executed), it brings up this weird cursor I've never seen, and brings up this error:

    pythonerr.png

    I went to investigate this /usr/bin/print and I found a Perl file. Am I missing something because Python uses C, not Perl (last I knew).

    If I use Terminal to do

    Code:
    python ~/Desktop/(path to file)/test.py
    it works fine.

    I'm going to restart my computer, and if that doesn't fix it, purge python and install it again.

    I'm on Ubuntu 16.04 LTS, Python 2.7.11, and if you need more details, just let me know!

    I'll report with results when I restart and reinstall!
    "Ubuntu isn't a tree, but if it was, it would be dead 'cause it only has 1 root!"
    "When you get the biology lesson, it turns into: bi - ooooooh - logy!"
    "Just use Ctrl + Shift + I."
    Quote Originally Posted by scoutchorton;
    Think smart, not hard...

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Python running Perl instead of Python?

    Does your file contain a "shebang" to indicate that it should be run using the python interpreter?

    Code:
    #!/usr/bin/python
    
    print "Hallo"
    Otherwise, the system will try to run it using the default shell, I think - which will treat `print` as the system command /usr/bin/print

    [Remember that - unlike some other OSes - the file extension has no particular significance on *nix]

  3. #3
    Join Date
    Dec 2015
    Location
    /home/
    Beans
    22
    Distro
    Ubuntu 17.04 Zesty Zapus

    Re: Python running Perl instead of Python?

    No, I'll have to try it. I've used it without it for so long, so I just asumed because it was a .py it would run python scripts...
    "Ubuntu isn't a tree, but if it was, it would be dead 'cause it only has 1 root!"
    "When you get the biology lesson, it turns into: bi - ooooooh - logy!"
    "Just use Ctrl + Shift + I."
    Quote Originally Posted by scoutchorton;
    Think smart, not hard...

  4. #4
    Join Date
    Dec 2015
    Location
    /home/
    Beans
    22
    Distro
    Ubuntu 17.04 Zesty Zapus

    Re: Python running Perl instead of Python?

    I restarted, didn't work. I did sudo apt-get pruge python2.7, and trying to repair damage now. I tried the shebang, and it worked!!
    "Ubuntu isn't a tree, but if it was, it would be dead 'cause it only has 1 root!"
    "When you get the biology lesson, it turns into: bi - ooooooh - logy!"
    "Just use Ctrl + Shift + I."
    Quote Originally Posted by scoutchorton;
    Think smart, not hard...

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •