The python command starts the the wrong version of the python interpreter

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











up vote
1
down vote

favorite












I am using Mac OS X Version 10.13.1 and I have just installed anaconda. I have created a virtual environment using the command



conda create -n py3 python=3


Then, I have started the python interpreter using the command



python


To my surprise, the preinstalled python 2.7 from /usr/bin showed up instead of python 3.6. In order to check what is going wrong I issued the command



which python


The result was even more surprising, I got the following:



/Users/karlstroetmann/anaconda2/envs/py3/bin/python


When I then invoked the command



/Users/karldrstroetmann/anaconda2/envs/py3/bin/python


I did get python 3.6.3. But I don't understand why I cannot invoke this version by just typping python. What am I missing here? Any hints would be very much appreciated.







share|improve this question




















  • hash -t python? Then try hash -r if it doesn't match & see.
    – Michael Homer
    Nov 12 '17 at 1:14















up vote
1
down vote

favorite












I am using Mac OS X Version 10.13.1 and I have just installed anaconda. I have created a virtual environment using the command



conda create -n py3 python=3


Then, I have started the python interpreter using the command



python


To my surprise, the preinstalled python 2.7 from /usr/bin showed up instead of python 3.6. In order to check what is going wrong I issued the command



which python


The result was even more surprising, I got the following:



/Users/karlstroetmann/anaconda2/envs/py3/bin/python


When I then invoked the command



/Users/karldrstroetmann/anaconda2/envs/py3/bin/python


I did get python 3.6.3. But I don't understand why I cannot invoke this version by just typping python. What am I missing here? Any hints would be very much appreciated.







share|improve this question




















  • hash -t python? Then try hash -r if it doesn't match & see.
    – Michael Homer
    Nov 12 '17 at 1:14













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am using Mac OS X Version 10.13.1 and I have just installed anaconda. I have created a virtual environment using the command



conda create -n py3 python=3


Then, I have started the python interpreter using the command



python


To my surprise, the preinstalled python 2.7 from /usr/bin showed up instead of python 3.6. In order to check what is going wrong I issued the command



which python


The result was even more surprising, I got the following:



/Users/karlstroetmann/anaconda2/envs/py3/bin/python


When I then invoked the command



/Users/karldrstroetmann/anaconda2/envs/py3/bin/python


I did get python 3.6.3. But I don't understand why I cannot invoke this version by just typping python. What am I missing here? Any hints would be very much appreciated.







share|improve this question












I am using Mac OS X Version 10.13.1 and I have just installed anaconda. I have created a virtual environment using the command



conda create -n py3 python=3


Then, I have started the python interpreter using the command



python


To my surprise, the preinstalled python 2.7 from /usr/bin showed up instead of python 3.6. In order to check what is going wrong I issued the command



which python


The result was even more surprising, I got the following:



/Users/karlstroetmann/anaconda2/envs/py3/bin/python


When I then invoked the command



/Users/karldrstroetmann/anaconda2/envs/py3/bin/python


I did get python 3.6.3. But I don't understand why I cannot invoke this version by just typping python. What am I missing here? Any hints would be very much appreciated.









share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '17 at 1:11









Carlos Ben Yussuf

82




82











  • hash -t python? Then try hash -r if it doesn't match & see.
    – Michael Homer
    Nov 12 '17 at 1:14

















  • hash -t python? Then try hash -r if it doesn't match & see.
    – Michael Homer
    Nov 12 '17 at 1:14
















hash -t python? Then try hash -r if it doesn't match & see.
– Michael Homer
Nov 12 '17 at 1:14





hash -t python? Then try hash -r if it doesn't match & see.
– Michael Homer
Nov 12 '17 at 1:14











2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:



type -a python


Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions.



For further discussion of which (no pun intended) commands to use to determine which programs are executed by the shell, see the following post:



  • Why not use "which"? What to use then?

Alternatively, you can also use the hash command itself to determine if a given command has been hashed, e.g:



hash -t python


You can also list all hashed commands by running hash without any arguments, i.e.:



hash


Similarly, you can use the alias command to check if a given command is an alias, e.g.:



alias python


And you can list all active aliases as well:



alias


To clear the cached Python program you can use the following command:



hash -d python


Alternatively, you can clear everything all at once:



hash -r


To clear a single alias you could use the unalias command, e.g.:



unalias python


Or you could clear all aliases at once:



unalias -a





share|improve this answer





























    up vote
    0
    down vote













    I have solved my problem, it was a stupid mistake: I had an alias for python in my .bashrc. I had forgotten about this alias and hence the problem resulted.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      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: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2funix.stackexchange.com%2fquestions%2f403972%2fthe-python-command-starts-the-the-wrong-version-of-the-python-interpreter%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote



      accepted










      It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:



      type -a python


      Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions.



      For further discussion of which (no pun intended) commands to use to determine which programs are executed by the shell, see the following post:



      • Why not use "which"? What to use then?

      Alternatively, you can also use the hash command itself to determine if a given command has been hashed, e.g:



      hash -t python


      You can also list all hashed commands by running hash without any arguments, i.e.:



      hash


      Similarly, you can use the alias command to check if a given command is an alias, e.g.:



      alias python


      And you can list all active aliases as well:



      alias


      To clear the cached Python program you can use the following command:



      hash -d python


      Alternatively, you can clear everything all at once:



      hash -r


      To clear a single alias you could use the unalias command, e.g.:



      unalias python


      Or you could clear all aliases at once:



      unalias -a





      share|improve this answer


























        up vote
        0
        down vote



        accepted










        It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:



        type -a python


        Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions.



        For further discussion of which (no pun intended) commands to use to determine which programs are executed by the shell, see the following post:



        • Why not use "which"? What to use then?

        Alternatively, you can also use the hash command itself to determine if a given command has been hashed, e.g:



        hash -t python


        You can also list all hashed commands by running hash without any arguments, i.e.:



        hash


        Similarly, you can use the alias command to check if a given command is an alias, e.g.:



        alias python


        And you can list all active aliases as well:



        alias


        To clear the cached Python program you can use the following command:



        hash -d python


        Alternatively, you can clear everything all at once:



        hash -r


        To clear a single alias you could use the unalias command, e.g.:



        unalias python


        Or you could clear all aliases at once:



        unalias -a





        share|improve this answer
























          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:



          type -a python


          Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions.



          For further discussion of which (no pun intended) commands to use to determine which programs are executed by the shell, see the following post:



          • Why not use "which"? What to use then?

          Alternatively, you can also use the hash command itself to determine if a given command has been hashed, e.g:



          hash -t python


          You can also list all hashed commands by running hash without any arguments, i.e.:



          hash


          Similarly, you can use the alias command to check if a given command is an alias, e.g.:



          alias python


          And you can list all active aliases as well:



          alias


          To clear the cached Python program you can use the following command:



          hash -d python


          Alternatively, you can clear everything all at once:



          hash -r


          To clear a single alias you could use the unalias command, e.g.:



          unalias python


          Or you could clear all aliases at once:



          unalias -a





          share|improve this answer














          It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:



          type -a python


          Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions.



          For further discussion of which (no pun intended) commands to use to determine which programs are executed by the shell, see the following post:



          • Why not use "which"? What to use then?

          Alternatively, you can also use the hash command itself to determine if a given command has been hashed, e.g:



          hash -t python


          You can also list all hashed commands by running hash without any arguments, i.e.:



          hash


          Similarly, you can use the alias command to check if a given command is an alias, e.g.:



          alias python


          And you can list all active aliases as well:



          alias


          To clear the cached Python program you can use the following command:



          hash -d python


          Alternatively, you can clear everything all at once:



          hash -r


          To clear a single alias you could use the unalias command, e.g.:



          unalias python


          Or you could clear all aliases at once:



          unalias -a






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '17 at 14:41

























          answered Nov 12 '17 at 1:14









          igal

          4,830930




          4,830930






















              up vote
              0
              down vote













              I have solved my problem, it was a stupid mistake: I had an alias for python in my .bashrc. I had forgotten about this alias and hence the problem resulted.






              share|improve this answer
























                up vote
                0
                down vote













                I have solved my problem, it was a stupid mistake: I had an alias for python in my .bashrc. I had forgotten about this alias and hence the problem resulted.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I have solved my problem, it was a stupid mistake: I had an alias for python in my .bashrc. I had forgotten about this alias and hence the problem resulted.






                  share|improve this answer












                  I have solved my problem, it was a stupid mistake: I had an alias for python in my .bashrc. I had forgotten about this alias and hence the problem resulted.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 '17 at 13:48









                  Carlos Ben Yussuf

                  82




                  82



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f403972%2fthe-python-command-starts-the-the-wrong-version-of-the-python-interpreter%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?