Python script compiling with 2.7 over 3 even with shebang

74 Views Asked by At

I'm trying to make a python script executable on a raspberry pi (unix), and it compiles with python2.7 even though I specify python3 in the shebang.

The shebang is: #!/usr/bin/env python3

I have also run the command alias python=python3

To make executable I have run chmod +x main.py then I run ./main.py

The problem is that I am trying to include sklearn modules, which are only correctly included with python3. The error I get is:

ImportError: No module named sklearn.multiclass

If I run the code with python3 main.py or python main.py it works, so I know the python3 alias works. Without the alias, python main.py gives the same error.

Anybody have any insight as to why this might be happening?

Edit (question answers):

This is not meant to be run on a virtual machine. I am trying to run with ./main.py

which python3 returns /usr/bin/python3

type python3 returns /usr/bin/python3

0

There are 0 best solutions below