Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I Get ImportError: No module named pathlib, even after installing pathlib with pip

This is my first time asking on this site, so sorry if my question is not layed out correctly

y@DESKTOP-MQJ3NCT:~/Real-Time-Voice-Cloning$ python demo_toolbox.py
Traceback (most recent call last):
  File "demo_toolbox.py", line 1, in <module>
    from pathlib import Path
ImportError: No module named pathlib

I have tried:

pip3 install pathlib

and:

sudo -H pip3 install pathlib

but continue to get the same error

I am using the windows store version of ubuntu 18 LTS and python 3.7

like image 228
helo Avatar asked Mar 02 '23 16:03

helo


1 Answers

When it comes to python, it's quite easy to make the mistake of just running "python ...". When you install python on windows "python" defaults to the python 2.7 installation ( probably changed now that 2.7 is no longer supported) if it is installed.

Ubuntu has the links "python2" and "python3" which makes so much more sense but can still lead to confusion.

If you have a local python Virtual environment, the "python" command defaults to the global install on windows (to further confuse people).

I find it generally best to create my own links to the global python "python27" and "python36" to avoid these confusions.

Same goes for pip. It's best to call

python3 -m pip install ... 

Also. PyCharm is the most amazing Python IDE in the world and it helps with so much.

like image 76
Parthanon Avatar answered Mar 05 '23 17:03

Parthanon