I have installed some Python packages with pip and some others with my package manager (pacman). Now, every time I want to update the system, it says that some files already exist, because it tries to install some dependency Python module which actaully I already have. How can I fix this issue?

To reproduce the issue, you can simply try to install something via pip and then the same package via a package manager, i.e.:

$ sudo pip install numpy

and then

$ sudo pacman -S python-numpy

closed as off-topic by slm Jul 16 '18 at 23:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Try to paste (as text) exactly the errors you get... – Patrick Mevzek Jul 16 '18 at 22:32
  • thing like "python-docutils: /usr/lib/python3.6/site-packages/docutils/writers/_html_base.py exists in filesystem" – fortea Jul 16 '18 at 22:42
  • @slm the problem can be reproduced by simpling installing something with pip and then trying to install it via any package manager. It is also Linux related and many users have this kind of problem (just google it to check) – fortea Jul 17 '18 at 13:35

First, you could remove them the way you installed them, with pip.

If that doesn't work, identify all files not owned by a package. You can use lostfiles to do this. Then manually remove those files.

Then, going forward, either use pacman to install all your python (ruby, node, whatever) packages, or use the --user switch to install to your $HOME.

  • Sorry, I've had some connection trouble, but this was a "fake" question (I just discovered the solution by myself and it was a while that I was googling it without success) :(){:|:};: – fortea Jul 16 '18 at 22:00
  • I have hundreds of modules installed, removing them would break the system and re-installing them by hand is absurd. – fortea Jul 16 '18 at 22:08
  • Removing them would not "break the system". How you decide to reinstall them is up to you, but that part could be scripted. – jasonwryan Jul 16 '18 at 22:10
  • If you write a few lines of script for removing files just of pip we could merge the answers... – fortea Jul 16 '18 at 22:15
  • Yes, it breaks the system if you don't reinstall them and if you are not sure that files you are removing are the ones that you are going to reinstall. – fortea Jul 16 '18 at 22:15

WARNING: this answer uses the --force option of the pacman command. You should use it if and only if you understand what you are doing!

  1. Export the list of packages installed through pip:

>>> pip freeze > packages.txt

  1. Launch this command: it will re-download and install through pacman packages installed from pip that are not marked as installed in the pacman database.

>>> for i in $(awk -F "==" '{print $1}' packages.txt); do sudo pacman -S --needed --force --noconfirm python-$i; done

  1. You can do the same with python2 by just adding 2 afterpython and pip in the above commands.

  2. Since now on, just use pacman, not pip. You can use pip to upgrade/downgrade to a particular version a package, if needed.

If you like, you can also use a script version:

pip freeze > packages.txt
for i in $(awk -F "==" '{print $1}' packages.txt)
     sudo pacman -S --needed --force --noconfirm python-$i

Save it to file, give execution permission to that file and run.

  • Recommedning the use of --force for a large number of packages is irresponsible at best, and explicitly contrary to the pacman developers' advice. – jasonwryan Jul 16 '18 at 22:00
  • Sorry, corrected with --overwrite – fortea Jul 16 '18 at 22:01
  • That doesn't fix the problem: --overwrite is supposed to be used judiciously. – jasonwryan Jul 16 '18 at 22:05
  • If you have another working solution, I'll be happy to use it :) – fortea Jul 16 '18 at 22:06
  • 1
    I'm done arguing with someone who clearly doesn't understand how pacman or Arch works. – jasonwryan Jul 16 '18 at 22:14

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