Make Python3.6 the default interpreter when running the command python filename.py in terminal?trying to install mysql-connector for python 3How to update pip3 sub-version?pip3 missing dependencyImportError: cannot import name 'main' after installing python3.6 and pipenvInstalling pip3How do I un-screw up a Python/Pip installation after doing the mistake of running sudo pip multiple times?Problem with python in Ubuntu 18.10
I am measuring a 9W LED with a clamp on ammeter. Why does it only draw 7.62W?
Is having your hand in your pocket during a presentation bad?
How much money should I save in order to generate $1000/month for the rest of my life?
What cluster of stars is this with a "dark donut" to one side?
one-liner vs script
Why has Donald Trump's popularity remained so stable over a rather long period of time?
Why didn't Trudy wear a breathing mask in Avatar?
Landing Hero: Product snippets VS illustrations
How did the Fried Liver Attack get its name?
Difference between $HOME and ~
3x3 self-descriptive squares
Why didn't Snape ask Dumbledore why he let "Moody" search his office?
What is the fastest way to move?
I pay for a service, but I miss the broadcast
What is /dev/null and why can't I use hx on it?
Concrete description of lift in Arens-Eells space
Find the percentage
A sentient carnivorous species trying to preserve life. How could they find a new food source?
Why do English transliterations of Arabic names have so many Qs in them?
How to Skip One Bullet in ITEMIZE?
Injection from two strings to one string
universal string conversion
Does UPDATE without WHERE clause lock a table in PostgreSQL?
Rat proofing compost bin but allowing worms in
Make Python3.6 the default interpreter when running the command python filename.py in terminal?
trying to install mysql-connector for python 3How to update pip3 sub-version?pip3 missing dependencyImportError: cannot import name 'main' after installing python3.6 and pipenvInstalling pip3How do I un-screw up a Python/Pip installation after doing the mistake of running sudo pip multiple times?Problem with python in Ubuntu 18.10
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have three versions of python on ubuntu 18.04
when running python -V
in terminal it produces Python 2.7.15rc1
and when running python3 -V
it produces Python 3.7.2
You could see the paths of python versions on my OS from this picture here is the screeshot
but when running pip install package-name
or pip3 install package-name
it installs the package
in python3.6
,
Now as all the packages installed on python3.6, I want to run my programs in terminal on python3.6 not Python 2.7.15rc1
or Python 3.7.2
as in the picture
My problem is:
when I run python filename.py
, it interpreted on Python 2.7.15rc1
so it produces an error that says package not found, and the same when running python3 filename.py
it interpreted on Python 3.7.2
and it produces an error that says package not found
Now I want to set Python3.6
to be the default interpreter when I run a program in the terminal because it has all the packages installed to it!
python python3
add a comment
|
I have three versions of python on ubuntu 18.04
when running python -V
in terminal it produces Python 2.7.15rc1
and when running python3 -V
it produces Python 3.7.2
You could see the paths of python versions on my OS from this picture here is the screeshot
but when running pip install package-name
or pip3 install package-name
it installs the package
in python3.6
,
Now as all the packages installed on python3.6, I want to run my programs in terminal on python3.6 not Python 2.7.15rc1
or Python 3.7.2
as in the picture
My problem is:
when I run python filename.py
, it interpreted on Python 2.7.15rc1
so it produces an error that says package not found, and the same when running python3 filename.py
it interpreted on Python 3.7.2
and it produces an error that says package not found
Now I want to set Python3.6
to be the default interpreter when I run a program in the terminal because it has all the packages installed to it!
python python3
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41
add a comment
|
I have three versions of python on ubuntu 18.04
when running python -V
in terminal it produces Python 2.7.15rc1
and when running python3 -V
it produces Python 3.7.2
You could see the paths of python versions on my OS from this picture here is the screeshot
but when running pip install package-name
or pip3 install package-name
it installs the package
in python3.6
,
Now as all the packages installed on python3.6, I want to run my programs in terminal on python3.6 not Python 2.7.15rc1
or Python 3.7.2
as in the picture
My problem is:
when I run python filename.py
, it interpreted on Python 2.7.15rc1
so it produces an error that says package not found, and the same when running python3 filename.py
it interpreted on Python 3.7.2
and it produces an error that says package not found
Now I want to set Python3.6
to be the default interpreter when I run a program in the terminal because it has all the packages installed to it!
python python3
I have three versions of python on ubuntu 18.04
when running python -V
in terminal it produces Python 2.7.15rc1
and when running python3 -V
it produces Python 3.7.2
You could see the paths of python versions on my OS from this picture here is the screeshot
but when running pip install package-name
or pip3 install package-name
it installs the package
in python3.6
,
Now as all the packages installed on python3.6, I want to run my programs in terminal on python3.6 not Python 2.7.15rc1
or Python 3.7.2
as in the picture
My problem is:
when I run python filename.py
, it interpreted on Python 2.7.15rc1
so it produces an error that says package not found, and the same when running python3 filename.py
it interpreted on Python 3.7.2
and it produces an error that says package not found
Now I want to set Python3.6
to be the default interpreter when I run a program in the terminal because it has all the packages installed to it!
python python3
python python3
edited Apr 17 at 12:57
Mustafa Abdullah
asked Apr 17 at 12:40
Mustafa AbdullahMustafa Abdullah
62 bronze badges
62 bronze badges
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41
add a comment
|
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41
add a comment
|
1 Answer
1
active
oldest
votes
On your system /usr/bin/python3
is likely a link to /usr/bin/python3.7
and can be changed to be /usr/bin/python3.6
. You will also find that /usr/bin/python
is a link to /usr/bin/python2.7
×
The link for python3
can be changed to be /usr/bin/python3.6
but making python
itself default to python3
is fraught with peril, because your system may have scripts written for python v2(*) with a #! /usr/bin/python
shebang and changing python
to be a python V3 interpreter will break them.
Another solution is to define a shell alias (in .bashrc)
alias python3=/usr/bin/python3.6
alias python=/usr/bin/python3.6
The good thing about this solution is that it only changes the meaning of python
for interactive shells, in scripts the aliases are ignored and you still use the default python
interpreter and so won't break anything.
(*) Find them with:
find /usr/ -type f -executable -exec grep -E -l '#!.+python[^3]' ;
add a comment
|
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1134645%2fmake-python3-6-the-default-interpreter-when-running-the-command-python-filename%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
On your system /usr/bin/python3
is likely a link to /usr/bin/python3.7
and can be changed to be /usr/bin/python3.6
. You will also find that /usr/bin/python
is a link to /usr/bin/python2.7
×
The link for python3
can be changed to be /usr/bin/python3.6
but making python
itself default to python3
is fraught with peril, because your system may have scripts written for python v2(*) with a #! /usr/bin/python
shebang and changing python
to be a python V3 interpreter will break them.
Another solution is to define a shell alias (in .bashrc)
alias python3=/usr/bin/python3.6
alias python=/usr/bin/python3.6
The good thing about this solution is that it only changes the meaning of python
for interactive shells, in scripts the aliases are ignored and you still use the default python
interpreter and so won't break anything.
(*) Find them with:
find /usr/ -type f -executable -exec grep -E -l '#!.+python[^3]' ;
add a comment
|
On your system /usr/bin/python3
is likely a link to /usr/bin/python3.7
and can be changed to be /usr/bin/python3.6
. You will also find that /usr/bin/python
is a link to /usr/bin/python2.7
×
The link for python3
can be changed to be /usr/bin/python3.6
but making python
itself default to python3
is fraught with peril, because your system may have scripts written for python v2(*) with a #! /usr/bin/python
shebang and changing python
to be a python V3 interpreter will break them.
Another solution is to define a shell alias (in .bashrc)
alias python3=/usr/bin/python3.6
alias python=/usr/bin/python3.6
The good thing about this solution is that it only changes the meaning of python
for interactive shells, in scripts the aliases are ignored and you still use the default python
interpreter and so won't break anything.
(*) Find them with:
find /usr/ -type f -executable -exec grep -E -l '#!.+python[^3]' ;
add a comment
|
On your system /usr/bin/python3
is likely a link to /usr/bin/python3.7
and can be changed to be /usr/bin/python3.6
. You will also find that /usr/bin/python
is a link to /usr/bin/python2.7
×
The link for python3
can be changed to be /usr/bin/python3.6
but making python
itself default to python3
is fraught with peril, because your system may have scripts written for python v2(*) with a #! /usr/bin/python
shebang and changing python
to be a python V3 interpreter will break them.
Another solution is to define a shell alias (in .bashrc)
alias python3=/usr/bin/python3.6
alias python=/usr/bin/python3.6
The good thing about this solution is that it only changes the meaning of python
for interactive shells, in scripts the aliases are ignored and you still use the default python
interpreter and so won't break anything.
(*) Find them with:
find /usr/ -type f -executable -exec grep -E -l '#!.+python[^3]' ;
On your system /usr/bin/python3
is likely a link to /usr/bin/python3.7
and can be changed to be /usr/bin/python3.6
. You will also find that /usr/bin/python
is a link to /usr/bin/python2.7
×
The link for python3
can be changed to be /usr/bin/python3.6
but making python
itself default to python3
is fraught with peril, because your system may have scripts written for python v2(*) with a #! /usr/bin/python
shebang and changing python
to be a python V3 interpreter will break them.
Another solution is to define a shell alias (in .bashrc)
alias python3=/usr/bin/python3.6
alias python=/usr/bin/python3.6
The good thing about this solution is that it only changes the meaning of python
for interactive shells, in scripts the aliases are ignored and you still use the default python
interpreter and so won't break anything.
(*) Find them with:
find /usr/ -type f -executable -exec grep -E -l '#!.+python[^3]' ;
answered Apr 17 at 15:06
xenoidxenoid
2,6701 gold badge6 silver badges18 bronze badges
2,6701 gold badge6 silver badges18 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1134645%2fmake-python3-6-the-default-interpreter-when-running-the-command-python-filename%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you setting the header on the file.py? #!/usr/bin/env python Header thread
– Ricardo
Apr 17 at 14:41