1

I tried installing 'pandas' and 'xlrd' using pip install but I get this error from python when I try and use the modules: ImportError: No module named xlrd. Same error when I use pandas. I have tried various methods from the internet to solve this issue including:

  • changing package permissions
  • using sudo pip install
  • adding PYTHONPATH export in the bash_profile file.
  • using pip3 because I have python 3

I even tried this approach https://stackoverflow.com/a/49602260, but in my case I already had the package location(which I got using pip show xlrd) inside the sys.path list.

None of the above approaches have worked for me.

Edit: I use VSCode as my IDE and I run my files through the inbuilt terminal.

Bababooey
  • 13
  • 3
  • Sounds like you have more than one version of python installed on your system. How, exactly, do you run the python code? Do you type `python script.py` on the command prompt, or do you use an IDE, or some other way? – John Gordon Mar 27 '22 at 19:52
  • `python3 -m pip install xlrd pandas`. Don't bother with `sudo` if it's not necessary: Python/pip will use a user installation instead. If your Python command is different, change it accordingly. – 9769953 Mar 27 '22 at 19:53
  • @JohnGordon Thanks for your reply! It made me realise that the problem is with the IDE and not pip as it works when I use the terminal to run. Any answers on why VScode is behaving that way? – Bababooey Mar 27 '22 at 19:56
  • Probably because VSCode is set up with the incorrect Python executable. – 9769953 Mar 27 '22 at 19:57
  • @9769953 Thanks a lot it works after changing the settings to the correct path – Bababooey Mar 27 '22 at 20:08
  • Run each of these commands to see where your Python and Pip installs are located: 'which python', 'which python3', 'which pip', 'which pip3'. Then try to run the python version with the full path from VSCode. – Captain Caveman Mar 27 '22 at 23:09

0 Answers0