1

I want to make python 3 as default in raspberry pi 3b and install scikit-learn and scikit-plot for the python 3 version. What are exact steps to be followed. Appreciate your input. Thank you

  • What do you mean by make python3 as default? – user67191 Jul 10 '17 at 5:16
  • @yamboy1, yes. Can it be done by adding 'alias python=python3' in the ~/.bashrc file and then typing alias python=python3. But then how to revert to python2. – Dattaprasad Jul 10 '17 at 5:17
  • @yamboy1, sorry for not mentioning it clearly. Making python 3 default means whenvever I open a py file, it should open in python 3 IDLE. And when I install any new package it should be for the python version 3. In my case, currently basic packages such as scipy and numpy are installed for python 2, but when I run a code in python 3 IDLE, I get error....Import Error: No module named 'scipy' – Dattaprasad Jul 10 '17 at 5:20
  • 1
    askubuntu.com/questions/320996/… covers the details you need to beaware of as for python2 after aliasing python3 create aa second alias for python2 – Steve Robillard Jul 10 '17 at 6:36
  • What operating system do you use? – Bex Aug 18 '17 at 8:43
2

If you run linux command ls -l python* within the directory, you will see that python is just a symlink to python2.7, if you know linux commands well enough, you can easily make a change to link python -> python3.

One more thing you need to aware is that in order to install packages for python3, you need to run pip3. This is probably the reason that you run into the case where "No module name 'script'" error. Again, run ls -l pip* to find out more.

You can also run pip3 list to check what packages are installed for python3.

  • 1
    For many reasons, it is not a good idea to point /usr/bin/python to python3. See for example stackoverflow.com/questions/43062608/… – Bex Aug 18 '17 at 8:52
  • @Bex, I won't recommend messing with the default installation either (which is the link that you referred to is doing). However, to put a symbolic link so that typing python to launch python3 instead of the default python2 is a different story, and do no harm for the fundamental system installation. – hcheung Aug 18 '17 at 9:35
  • 1
    Instead of changing the default system-wide you could change it just for your pi-user. Do this: sudo apt install python3; mkdir ~/bin; ln -s /usr/bin/python3 ~/bin/python. Log your user out and log back in. Do this: which python, This should return /home/pi/bin/python. Now everthing under this user will use the symlink which points to python3. Delete ~/bin/python, log out and back in to revert this change. – MadMike Aug 18 '17 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.