How to fix "bad interpreter" problem when running pip3 on Ubuntu 20.04 WSL?

I have Cygwin on Windows10 and now I've installed Ubuntu 20.04 (WSL) and all it seems fine, except for Python3.

I've intalled python3 and pip3 but when I try to use it I get the "bad interpreter" message shown below, and is pointing to the Python3 installed on Cygwin path.

$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
$
$ pip3 install pandas
-bash: /mnt/d/d/cygwin64/bin/pip3: /usr/bin/python3.6: bad interpreter: No such file or directory

I've tried to delete/replace symlink as mentioned in this thread like this, but didn't work.

$ sudo rm /usr/bin/python3
$ sudo ln -sf /usr/bin/python3.8 /usr/bin/python3

How to fix this issue? Thanks in advance.


Solution 1:

  • Why did you type pip3 install pandas instead of python3.8 -m pip install pandas ? python3.8 in this command is the target interpreter.

  • There's no need to use pip to install Pandas in Ubuntu 20.04. The python3-pandas package is in the default Ubuntu 20.04 repositories. To install it type:

    sudo apt update  
    sudo apt install python3.8 python3-pandas