0

Default python is 2.7; default python3 is 3.6, which is the version I use; Ubuntu version 18.04. I'm trying to get newly downloaded python libraries to be installed in a python 3 library.

charles@BW2:~$ pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
  from pip import main
ImportError: cannot import name 'main'

What to do?

8
  • Instead of "$ pip..." do "$ python3 -m pip..."?? Also check whether your current dir has a file called "main.py" – Rusi Aug 14 '20 at 15:48
  • "$ python3 -m pip --version" yields the pip in the python 2.7 library. Using pip3 instead yields a "No module named pip3" error. There is no main.py in /usr/bin/. – cbro630 Aug 14 '20 at 16:13
  • And if you just start python3 at shell what version is shown? – Rusi Aug 14 '20 at 16:14
  • did you actually install python3-pip? (if there's no module named pip) – Philip Couling Aug 14 '20 at 16:14
  • 1
    Thank you, this has pointed me to the correct explanation of the problem. – cbro630 Aug 17 '20 at 21:56
0
python3 -m pip ARG [ARG [...]]

or

/path/to/python3 -m pip ARG [ARG [...]]

The latter is the typical way to invoke a module such as pip from a specific interpreter. The former will only work if python3 is on your PATH and is a valid interpreter.

1
  • @cbro630, Unfortunately due to limitations I cannot yet comment on the question itself, but have you considered (1) installing a second, newer Python interpreter and (2) creating a virtual environment for installing libraries? Although these do not address your original issue, they may provide a suitable workaround. – Jordan Deyton Aug 18 '20 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.