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;









1















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!










share|improve this question


























  • Are you setting the header on the file.py? #!/usr/bin/env python Header thread

    – Ricardo
    Apr 17 at 14:41


















1















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!










share|improve this question


























  • Are you setting the header on the file.py? #!/usr/bin/env python Header thread

    – Ricardo
    Apr 17 at 14:41














1












1








1








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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











1 Answer
1






active

oldest

votes


















0
















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]' ;





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',
    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
    );



    );














    draft saved

    draft discarded
















    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









    0
















    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]' ;





    share|improve this answer





























      0
















      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]' ;





      share|improve this answer



























        0














        0










        0









        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]' ;





        share|improve this answer













        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]' ;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 17 at 15:06









        xenoidxenoid

        2,6701 gold badge6 silver badges18 bronze badges




        2,6701 gold badge6 silver badges18 bronze badges































            draft saved

            draft discarded















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?