0

I have many different versions of Python, but a version that I use and that terminal show me if use command Python – version is 3.10.0.

When I use command pip list I got a big list of library, including the one I recently installed odfpy.

I open VsCode, choose Python version 3.10.0 and try to import odf but... ModuleNotFoundError: No module named 'odf'

For sure I need to set something on VsCode or change some configuration in Linux but I cannot find a normal explanation of how to solve this issue.

If I change the Python version in VsCode with 3.8.10, odfpy (and also Django just installed) is recognized. So I suppose that, even if the Python version selected on the terminal is 3.10.0, when I pip install something, is installed on version 3.8.10. How do you manage this?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    Possibly vs code is pointing to a different installation of Python or is using a different environment. Look deeper into Vs code settings. – Tarik Dec 12 '21 at 11:09
  • 1
    Please post the solution in the answer space. Do not edit the question – Dharman Dec 12 '21 at 11:35
  • Multiple versions of `pip` is covered here - https://stackoverflow.com/questions/2812520/dealing-with-multiple-python-versions-and-pip – Rolf of Saxony Dec 12 '21 at 11:43
  • You can verify the specific python location listed in your workspace settings json (command palette ==> workspace settings json). Use this specific python to list your pip packages e.g. using `your-specific-python-3.10 -m pip list` - odf is likely not there, because you probably installed it for a different python... – Yuri Feldman Dec 12 '21 at 11:44
  • (Accordingly, you can `your-specific-python-3.10 -m pip install odfpy` to install it, but best practice is to work with a python virtual environment https://stackoverflow.com/questions/41573587/ will make life much easier) – Yuri Feldman Dec 12 '21 at 11:50

3 Answers3

0

Please check which pip you are using through the command of pip --version.

After you switch the python interpreter in the VSCode, please create a new terminal, and make sure it has activated the environment you have selected.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

I also use VS code and use Python 3.10 and i had try to download the odfpy which has gone alright, i use the command python -m pip install odfpy

try and see if it work for you though.

If it does not work, maybe try and create a virtual environment if you haven't created it yet.

cong le
  • 25
  • 4
0

In my case i was getting same error while using import-export django module. Installing odf library didn't worked got same error. I resolve this issue by simply pip install tablib==0.14.0.