no module librepo after installing pytorch on fedo

2019-07-13 06:14发布

I had to install pytorch with conda, and next I had this error when trying to upgrade system :

sudo dnf upgrade
Traceback (most recent call last):
  File "/bin/dnf", line 57, in <module>
    from dnf.cli import main
  File "/usr/lib/python3.6/site-packages/dnf/__init__.py", line 31, in <module>
    import dnf.base
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 26, in <module>
    from dnf.comps import CompsQuery
  File "/usr/lib/python3.6/site-packages/dnf/comps.py", line 29, in <module>
    import dnf.util
  File "/usr/lib/python3.6/site-packages/dnf/util.py", line 32, in <module>
    import librepo

ModuleNotFoundError: No module named 'librepo'

I saw some answer that uses yum-deprecated for re install python, but it seems I don't have it on my machine. I don't want to reinstall linux another time, and I'm searching for kind an answer for that problem.

When installing pytorch via conda, it also installed cuda. Maybe it can be a problem ? Before this, I remember (not sure, but kind of) I was running with python2.7 by default, and now it is python 3.6..

2条回答
够拽才男人
2楼-- · 2019-07-13 06:50

First the magic one-liner to fix things:

echo 'import sys;sys.path += ["/usr/lib64/python3.6/site-packages/", "/usr/lib64/python3.6/"]' | sudo tee /usr/lib/python3.6/site-packages/lib64.pth

I got the same error after using conda to install jupyterlab. For some reason conda installed its own version of python which shadows fedora's one. Conda's python searches libraries from /usr/lib/ while fedora's also searches /usr/lib64/. On most linux distros /usr/lib/ is a link for /usr/lib64/ or the other way so either one can be used. librepo is installed in /usr/lib64/.

My conclusions:

  • Fedora is not completely compatible with conda.
  • Fedora bug reports get closed as duplicate with links to obviously unrelated reports.
查看更多
倾城 Initia
3楼-- · 2019-07-13 07:04

I have stumbled upon the same issue in Fedora 28. I used anaconda as root to update packages system wide, and this broke dnf with the message

ModuleNotFoundError: No module named 'librepo'

yum-deprecated did not work, although Fedora installed it for me after automatically querying for it (a bit strange that this worked since dnf and yum did not work). In order to fix the issue, I deleted the existing libpython, downloaded the python3 and python3-lib rpms from rpmfind, and installed the new rpms

rm -rf /usr/lib/libpython3*.*
rpm -iv --replacepkgs python3-3.6.6-1.fc28.x86_64.rpm
rpm -iv --replacepkgs python3-libs-3.6.6-1.fc28.x86_64.rpm

Now I know it is better to use pip than anaconda system wide.

查看更多
登录 后发表回答