Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo python wrong version

Tags:

I get python 2.7 when running sudo. I've tried changing my .bash_profile and .bashrc from my original user and root, but to no avail.

$ python
Python 3.5.2 (default, Oct 11 2016, 05:05:28) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$ sudo python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

I've alias python='python3' in both bash configs in both users and sourced them.

How do I get python 3.5 to load with sudo python?

EDIT: This is on OSX EDIT2: I've also tried looking at which python.

$ which python
/usr/bin/python
$ sudo which python
/usr/bin/python
like image 672
Alexander Kleinhans Avatar asked Dec 14 '16 05:12

Alexander Kleinhans


1 Answers

As a possible workaround you can add to your bash_aliases (or similar to it):

alias python='/usr/bin/python3'
alias sudo='sudo '

And then:

. .bashrc
like image 55
Nurjan Avatar answered Oct 11 '22 11:10

Nurjan