2

My question is similar to this one... python3-pip installed but pip3 command not found?

I am using Debian 9.6 and python 3.6.

My problem is: I have installed python3-pip with apt-get install python3-pip, but unfortunately I can't get it work.
(As far as I know pip should be preinstalled... anyway)

When I type pip3, I get the output

~#pip3
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ModuleNotFoundError: No module named 'pip'

Typing "dpkg -L python3-pip" returns

/.
/usr
/usr/bin
/usr/bin/pip3
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/pip
/usr/lib/python3/dist-packages/pip/__init__.py
/usr/lib/python3/dist-packages/pip/__main__.py
/usr/lib/python3/dist-packages/pip/_vendor
/usr/lib/python3/dist-packages/pip/_vendor/__init__.py
/usr/lib/python3/dist-packages/pip/basecommand.py
/usr/lib/python3/dist-packages/pip/baseparser.py
/usr/lib/python3/dist-packages/pip/cmdoptions.py
/usr/lib/python3/dist-packages/pip/commands
/usr/lib/python3/dist-packages/pip/commands/__init__.py
/usr/lib/python3/dist-packages/pip/commands/check.py
/usr/lib/python3/dist-packages/pip/commands/completion.py
/usr/lib/python3/dist-packages/pip/commands/download.py
/usr/lib/python3/dist-packages/pip/commands/freeze.py
/usr/lib/python3/dist-packages/pip/commands/hash.py
/usr/lib/python3/dist-packages/pip/commands/help.py
/usr/lib/python3/dist-packages/pip/commands/install.py
/usr/lib/python3/dist-packages/pip/commands/list.py
/usr/lib/python3/dist-packages/pip/commands/search.py
/usr/lib/python3/dist-packages/pip/commands/show.py
/usr/lib/python3/dist-packages/pip/commands/uninstall.py
/usr/lib/python3/dist-packages/pip/commands/wheel.py
/usr/lib/python3/dist-packages/pip/compat
/usr/lib/python3/dist-packages/pip/compat/__init__.py
/usr/lib/python3/dist-packages/pip/compat/dictconfig.py
/usr/lib/python3/dist-packages/pip/download.py
/usr/lib/python3/dist-packages/pip/exceptions.py
/usr/lib/python3/dist-packages/pip/index.py
/usr/lib/python3/dist-packages/pip/locations.py
/usr/lib/python3/dist-packages/pip/models
/usr/lib/python3/dist-packages/pip/models/__init__.py
/usr/lib/python3/dist-packages/pip/models/index.py
/usr/lib/python3/dist-packages/pip/operations
/usr/lib/python3/dist-packages/pip/operations/__init__.py
/usr/lib/python3/dist-packages/pip/operations/check.py
/usr/lib/python3/dist-packages/pip/operations/freeze.py
/usr/lib/python3/dist-packages/pip/pep425tags.py
/usr/lib/python3/dist-packages/pip/req
/usr/lib/python3/dist-packages/pip/req/__init__.py
/usr/lib/python3/dist-packages/pip/req/req_file.py
/usr/lib/python3/dist-packages/pip/req/req_install.py
/usr/lib/python3/dist-packages/pip/req/req_set.py
/usr/lib/python3/dist-packages/pip/req/req_uninstall.py
/usr/lib/python3/dist-packages/pip/status_codes.py
/usr/lib/python3/dist-packages/pip/utils
/usr/lib/python3/dist-packages/pip/utils/__init__.py
/usr/lib/python3/dist-packages/pip/utils/appdirs.py
/usr/lib/python3/dist-packages/pip/utils/build.py
/usr/lib/python3/dist-packages/pip/utils/deprecation.py
/usr/lib/python3/dist-packages/pip/utils/encoding.py
/usr/lib/python3/dist-packages/pip/utils/filesystem.py
/usr/lib/python3/dist-packages/pip/utils/glibc.py
/usr/lib/python3/dist-packages/pip/utils/hashes.py
/usr/lib/python3/dist-packages/pip/utils/logging.py
/usr/lib/python3/dist-packages/pip/utils/outdated.py
/usr/lib/python3/dist-packages/pip/utils/packaging.py
/usr/lib/python3/dist-packages/pip/utils/setuptools_build.py
/usr/lib/python3/dist-packages/pip/utils/ui.py
/usr/lib/python3/dist-packages/pip/vcs
/usr/lib/python3/dist-packages/pip/vcs/__init__.py
/usr/lib/python3/dist-packages/pip/vcs/bazaar.py
/usr/lib/python3/dist-packages/pip/vcs/git.py
/usr/lib/python3/dist-packages/pip/vcs/mercurial.py
/usr/lib/python3/dist-packages/pip/vcs/subversion.py
/usr/lib/python3/dist-packages/pip/wheel.py
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/entry_points.txt
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/not-zip-safe
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/requires.txt
/usr/lib/python3/dist-packages/pip-9.0.1.egg-info/top_level.txt
/usr/share
/usr/share/doc
/usr/share/doc/python3-pip
/usr/share/doc/python3-pip/changelog.Debian.gz
/usr/share/doc/python3-pip/changelog.gz
/usr/share/doc/python3-pip/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pip3.1.gz

I also tried to reinstall it with apt-get install python3-pip --reinstall, but this changed nothing.

Trying to run pip over python3 -m pip install <package> or python3 -m pip3 install <package> results in "no module named pip/pip3".

I tried to get this working now for weeks, and I would highly appreciate any help I get!

GileBrt
  • 103
  • 3
AlexanderH
  • 21
  • 1
  • 3
  • What does `python -c "import sys; print(sys.path)"` show? Is there `/usr/lib/python3/dist-packages` among the paths? – mportes Jan 09 '19 at 10:08
  • It seems you are running pip3 as root. Have you tried to install and run it as a normal user? In that case, pip should be located within your home directory, for example `~/.local/lib/python3.6/site-packages` on Ubuntu (I am not sure about Debian). – mportes Jan 09 '19 at 10:18
  • First of all, thanks for the quick replies... @myrmica it shows `['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']` ...I can't see the `/usr/lib/python3/dist-packages` – AlexanderH Jan 12 '19 at 19:22
  • Running as normal user tells me to log in as root ... `E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? ` – AlexanderH Jan 12 '19 at 19:27
  • However, `python3 -c "import sys; print(sys.path)"` Shows `['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages'] ` Don't know is this is relevant... – AlexanderH Jan 12 '19 at 19:42
  • Yes, there should have been `python3` in my first comment, sorry for that. Can you locate pip and pip3 using `which -a pip` and `which -a pip3`? (please try both as a user and as root, and show results) – mportes Jan 14 '19 at 10:07
  • `which -a pip` returns /usr/bin/pip/, both as user and root...`which -a pip3`shows /usr/bin/pip3 (again as user and as root) – AlexanderH Jan 14 '19 at 19:50
  • I just printed the content of the file to the terminal with 'cat pip3'. It says `#!/usr/bin/python3 # GENERATED BY DEBIAN import sys # Run the main entry point, similarly to how setuptools does it, but because # we didn't install the actual entry point from setup.py, don't use the # pkg_resources API. from pip import main if __name__ == '__main__': sys.exit(main()) ` - Btw Sorry, I don't know how use newlines in the comments – AlexanderH Jan 14 '19 at 19:54
  • Same for `cat pip`, only the interpreter is different: `#!/usr/bin/python` – AlexanderH Jan 14 '19 at 19:59
  • Well, that's identical to what I have in `usr/bin/`. However, I also have both pips in `usr/local/bin/`, as well as in `~/.local/bin/` as a user. These have a different import `from pip._internal import main`. – mportes Jan 14 '19 at 21:33
  • Sorry for replying so late; I decided to simply reinstall my OS...Anyway thanks a lot for your help! I probably messed something up when I experimented with some of the settings... – AlexanderH Jan 27 '19 at 17:34

1 Answers1

0
python3.9 -m pip install pip

this could help

Nilanj
  • 1
  • 1