Unable to execute python script directly

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












I have a python script (peepdf.py) that I would like to execute directly by simple typing it in terminal then pass it the parameters it expects. To do this, I moved the folder which contains the script and other dependencies to /usr/local/bin directory then added to that full path to the ~/.bashrc file so that it becomes persistent.



Nonetheless, now when I type the command in terminal, I get this:



/usr/bin/env: ‘python’: No such file or directory


So I checked and I do have python installed since I went to the directory /usr/bin and saw it there python3 and python2.7, etc.



The only way I am able to run my script is by typing:



/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf 


Any way to make this script more accessible in terms of writing?



Update: Here is the line added to the .bashrc



export PATH=$PATH:/usr/local/bin/peepdf_0.3






share|improve this question


























    up vote
    2
    down vote

    favorite












    I have a python script (peepdf.py) that I would like to execute directly by simple typing it in terminal then pass it the parameters it expects. To do this, I moved the folder which contains the script and other dependencies to /usr/local/bin directory then added to that full path to the ~/.bashrc file so that it becomes persistent.



    Nonetheless, now when I type the command in terminal, I get this:



    /usr/bin/env: ‘python’: No such file or directory


    So I checked and I do have python installed since I went to the directory /usr/bin and saw it there python3 and python2.7, etc.



    The only way I am able to run my script is by typing:



    /usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf 


    Any way to make this script more accessible in terms of writing?



    Update: Here is the line added to the .bashrc



    export PATH=$PATH:/usr/local/bin/peepdf_0.3






    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have a python script (peepdf.py) that I would like to execute directly by simple typing it in terminal then pass it the parameters it expects. To do this, I moved the folder which contains the script and other dependencies to /usr/local/bin directory then added to that full path to the ~/.bashrc file so that it becomes persistent.



      Nonetheless, now when I type the command in terminal, I get this:



      /usr/bin/env: ‘python’: No such file or directory


      So I checked and I do have python installed since I went to the directory /usr/bin and saw it there python3 and python2.7, etc.



      The only way I am able to run my script is by typing:



      /usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf 


      Any way to make this script more accessible in terms of writing?



      Update: Here is the line added to the .bashrc



      export PATH=$PATH:/usr/local/bin/peepdf_0.3






      share|improve this question














      I have a python script (peepdf.py) that I would like to execute directly by simple typing it in terminal then pass it the parameters it expects. To do this, I moved the folder which contains the script and other dependencies to /usr/local/bin directory then added to that full path to the ~/.bashrc file so that it becomes persistent.



      Nonetheless, now when I type the command in terminal, I get this:



      /usr/bin/env: ‘python’: No such file or directory


      So I checked and I do have python installed since I went to the directory /usr/bin and saw it there python3 and python2.7, etc.



      The only way I am able to run my script is by typing:



      /usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf 


      Any way to make this script more accessible in terms of writing?



      Update: Here is the line added to the .bashrc



      export PATH=$PATH:/usr/local/bin/peepdf_0.3








      share|improve this question













      share|improve this question




      share|improve this question








      edited May 4 at 8:39









      dessert

      19.6k55594




      19.6k55594










      asked May 4 at 8:14









      ksa_coder

      1134




      1134




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          I advise against changing the PATH variable for just a single script. If you're not going to use it in any other environment, you can simply change your script's shebang to point to python2.7 directly:





          #!/usr/bin/python2.7


          This way you can execute it with the full path, e.g.:



          /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf


          If you however want to execute it conveniently with just a single keyword, I'd define an alias in the ~/.bash_aliases file, let's take “peepdf”:



          alias peepdf='/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py'


          With that you're able to run your script simply with e.g.:



          peepdf -i test.pdf





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031882%2funable-to-execute-python-script-directly%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            I advise against changing the PATH variable for just a single script. If you're not going to use it in any other environment, you can simply change your script's shebang to point to python2.7 directly:





            #!/usr/bin/python2.7


            This way you can execute it with the full path, e.g.:



            /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf


            If you however want to execute it conveniently with just a single keyword, I'd define an alias in the ~/.bash_aliases file, let's take “peepdf”:



            alias peepdf='/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py'


            With that you're able to run your script simply with e.g.:



            peepdf -i test.pdf





            share|improve this answer
























              up vote
              3
              down vote



              accepted










              I advise against changing the PATH variable for just a single script. If you're not going to use it in any other environment, you can simply change your script's shebang to point to python2.7 directly:





              #!/usr/bin/python2.7


              This way you can execute it with the full path, e.g.:



              /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf


              If you however want to execute it conveniently with just a single keyword, I'd define an alias in the ~/.bash_aliases file, let's take “peepdf”:



              alias peepdf='/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py'


              With that you're able to run your script simply with e.g.:



              peepdf -i test.pdf





              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                I advise against changing the PATH variable for just a single script. If you're not going to use it in any other environment, you can simply change your script's shebang to point to python2.7 directly:





                #!/usr/bin/python2.7


                This way you can execute it with the full path, e.g.:



                /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf


                If you however want to execute it conveniently with just a single keyword, I'd define an alias in the ~/.bash_aliases file, let's take “peepdf”:



                alias peepdf='/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py'


                With that you're able to run your script simply with e.g.:



                peepdf -i test.pdf





                share|improve this answer












                I advise against changing the PATH variable for just a single script. If you're not going to use it in any other environment, you can simply change your script's shebang to point to python2.7 directly:





                #!/usr/bin/python2.7


                This way you can execute it with the full path, e.g.:



                /usr/local/bin/peepdf_0.3/peepdf.py -i test.pdf


                If you however want to execute it conveniently with just a single keyword, I'd define an alias in the ~/.bash_aliases file, let's take “peepdf”:



                alias peepdf='/usr/bin/python2.7 /usr/local/bin/peepdf_0.3/peepdf.py'


                With that you're able to run your script simply with e.g.:



                peepdf -i test.pdf






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 4 at 8:35









                dessert

                19.6k55594




                19.6k55594






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031882%2funable-to-execute-python-script-directly%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Which professions warranted travel in Medieval times?

                    How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

                    Trouble downloading packages list due to a “Hash sum mismatch” error