Unable to execute python script directly


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
bash python
add a comment |Â
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
bash python
add a comment |Â
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
bash python
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
bash python
edited May 4 at 8:39


dessert
19.6k55594
19.6k55594
asked May 4 at 8:14


ksa_coder
1134
1134
add a comment |Â
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered May 4 at 8:35


dessert
19.6k55594
19.6k55594
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password