Unable to use pacman-mirrors

After some strange mishap ( HDD disappeared from the system during a pacman update ) …
although already had a list of installed packages and reinstalled them with

sudo pacman -S $( list.txt)

At the end it gave some errors related to python and now
I am unable to execute pacman-mirrors

getting this kind of error:

$ pacman-mirrors
Traceback (most recent call last):
  File "/bin/pacman-mirrors", line 5, in <module>
    from pacman_mirrors.pacman_mirrors import start
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 30, in <module>
    from pacman_mirrors.builder import common, fasttrack, interactive
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/builder/common.py", line 24, in <module>
    from pacman_mirrors.builder.builder import build_pool
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/builder/builder.py", line 26, in <module>
    from pacman_mirrors.functions.outputFn import write_custom_mirrors_json
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/outputFn.py", line 23, in <module>
    from pacman_mirrors.functions import customFn
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/customFn.py", line 22, in <module>
    from pacman_mirrors.functions import defaultFn
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/defaultFn.py", line 23, in <module>
    from pacman_mirrors.functions import pools
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/pools.py", line 23, in <module>
    from pacman_mirrors.functions.httpFn import get_ip_country
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 36, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

As far as can tell something is wrong with python …

Tried to reinstall python by calling

pacman -S python

With no errors nor strange messages whatsoever …

Any ideas how to solve this ?

want python-requests package

1 Like

That is strange - the pacman-mirrors package depends on python-requests.

 $ pamac info pacman-mirrors
Name                  : pacman-mirrors
Version               : 4.24.1-2
Description           : Manjaro Linux mirror list for use by pacman
URL                   : https://gitlab.manjaro.org/applications/pacman-mirrors
Licenses              : GPL-3.0-or-later
Repository            : core
Installed Size        : 883,0 kB
Groups                : --
Depends On            : python python-npyscreen python-requests
Optional Dependencies : gtk3: for interactive mode (GUI) [Installed]
                        python-gobject: for interactive mode (GUI) [Installed]
Required By           : libpamac manjaro-tools-base-git pacman pacman-contrib
Optional For          : --
Provides              : pacman-mirrorlist=4.24.1-2
Replaces              : --
Conflicts With        : pacman-mirrorlist reflector
Packager              : Mark Wagie <mark@manjaro.org>
Build Date            : lør 27 apr 2024 19:39:18 CEST
Install Date          : man 27 maj 2024 10:07:16 CEST
Install Reason        : Installed as a dependency for another package
Validated By          : Signature
Backup files          : /etc/pacman-mirrors.conf

I just wanted to say I have the same problem:

sudo pacman-mirrors --continent
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 227, in check_internet_connection
    resp = requests.get(host, timeout=maxwait)
           ^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pacman-mirrors", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 127, in start
    app.run()
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 96, in run
    self.network = httpFn.check_internet_connection(tty=self.tty)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 230, in check_internet_connection
    except (requests.exceptions.ConnectionError,) as connError:
            ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'exceptions'

And I also had a “mishap” when I updated last friday - the system froze (kernel panic or smt), then I had to spend the afternoon trying to fix it, since the lastest kernel I had went missing. After usb chroot update, it started but I cannot update. I get PGP errors and nothign can be installed. When I try to change the mirrors I get the same error. (I tried fixing system time etc, nothing helps so far - packages get downloaded and then it gives PGP error).

I have no idea what is is up with your system(s)

We have a test suite for pacman-mirrors - which is used when coding to check that everything is as expected.

Those tests pass - all 146 …

(pacman-mirrors-vlHEH9vO-py3.12) /a/projects/repos/manjaro/pacman-mirrors git:[master]
poetry run pytest
============================== test session starts ==============================
platform linux -- Python 3.12.3, pytest-7.4.4, pluggy-1.4.0
rootdir: /a/projects/repos/manjaro/pacman-mirrors
plugins: cov-4.1.0
collected 146 items                                                             

tests/test_command_line_parse.py .......                                  [  4%]
tests/test_commands.py .........                                          [ 10%]
tests/test_default_config.py .......                                      [ 15%]
tests/test_httpfn.py .                                                    [ 16%]
tests/test_inital_values.py ..........                                    [ 23%]
tests/test_pacman_mirrors.py ...                                          [ 25%]
tests/test_txt_colors.py ...                                              [ 27%]
tests/test_txt_error_types.py ..                                          [ 28%]
tests/test_txt_help_arg_messages.py ...................                   [ 41%]
tests/test_txt_interactive_messages.py ............                       [ 50%]
tests/test_txt_message_types.py ...                                       [ 52%]
tests/test_txt_messages.py .............................................  [ 82%]
tests/test_txt_mirror_status.py ....                                      [ 85%]
tests/test_txt_non_translatable.py .....                                  [ 89%]
tests/test_txt_options.py ..                                              [ 90%]
tests/test_txt_special_words.py ..............                            [100%]

======================== 146 passed in 79.28s (0:01:19) =========================

And on my workstation - no issues - same goes for my laptops.

03:16:35 ○ [fh@tiger] ~
 $ sudo pacman-mirrors --continent
::INFO Downloading mirrors from Manjaro
::INFO => Mirror pool: https://repo.manjaro.org/mirrors.json
::INFO => Mirror status: https://repo.manjaro.org/status.json
::INFO User generated mirror list
::------------------------------------------------------------
::INFO Custom mirror file saved: /var/lib/pacman-mirrors/custom-mirrors.json
::INFO Using default mirror file
::INFO Querying mirrors - This may take some time
  0.207 Austria        : https://mirror.easyname.at/manjaro/
  0.224 Belgium        : http://ftp.belnet.be/mirrors/manjaro/repos/
  0.260 Belgium        : https://mirror.futureweb.be/manjaro/
  0.882 Bulgaria       : https://manjaro.ipacct.com/manjaro/
  0.331 France         : https://mirror.ibakerserver.pt/manjaro/
  0.317 France         : https://manjaro.ynh.ovh/
  0.182 Germany        : https://mirror.alpix.eu/manjaro/
  0.262 Germany        : https://ftp.gwdg.de/pub/linux/manjaro/
  0.325 Germany        : https://mirror.23m.com/manjaro/
  0.111 Germany        : https://manjaro.kurdy.org/
  0.645 Hungary        : https://quantum-mirror.hu/mirrors/pub/manjaro/
  0.274 Netherlands    : https://manjaro.mirrors.lavatech.top/
  0.651 Netherlands    : https://ftp.nluug.nl/pub/os/Linux/distr/manjaro/
  0.158 Sweden         : https://ftp.lysator.liu.se/pub/manjaro/
  0.755 Sweden         : https://ftpmirror1.infania.net/mirror/manjaro/
  0.237 Switzerland    : https://mirror.init7.net/manjaro/
  0.335 United_Kingdom : http://manjaro.mirrors.uk2.net/
::INFO Writing mirror list
::Germany         : https://manjaro.kurdy.org/unstable
::Sweden          : https://ftp.lysator.liu.se/pub/manjaro/unstable
::Germany         : https://mirror.alpix.eu/manjaro/unstable
::Austria         : https://mirror.easyname.at/manjaro/unstable
::Belgium         : http://ftp.belnet.be/mirrors/manjaro/repos/unstable
::Switzerland     : https://mirror.init7.net/manjaro/unstable
::Belgium         : https://mirror.futureweb.be/manjaro/unstable
::Germany         : https://ftp.gwdg.de/pub/linux/manjaro/unstable
::Netherlands     : https://manjaro.mirrors.lavatech.top/unstable
::France          : https://manjaro.ynh.ovh/unstable
::Germany         : https://mirror.23m.com/manjaro/unstable
::France          : https://mirror.ibakerserver.pt/manjaro/unstable
::United_Kingdom  : http://manjaro.mirrors.uk2.net/unstable
::Hungary         : https://quantum-mirror.hu/mirrors/pub/manjaro/unstable
::Netherlands     : https://ftp.nluug.nl/pub/os/Linux/distr/manjaro/unstable
::Sweden          : https://ftpmirror1.infania.net/mirror/manjaro/unstable
::Bulgaria        : https://manjaro.ipacct.com/manjaro/unstable
::INFO Mirror list generated and saved to: /etc/pacman.d/mirrorlist
03:17:01 ○ [fh@tiger] ~
 $ python --version
Python 3.12.3
03:17:08 ○ [fh@tiger] ~
 $ pacman-mirrors --version
Version 4.24.0

It does work here too.

But I keep forgetting to mention that there are multiple typos in the the man page for it.

   –continent
         Creates a custom mirror pool from geolocation
  • Which countries has mirrors?

    pacman-mirrors –country-list
  • I want only https and http protocol in that order

    sudo pacman-mirrors –country Germany,France –api –set-branch unstable –procotol https http

  • Create a mirrorlist with German mirrors

    sudo pacman-mirrors –country Germany

  • If you want more countries in your mirrorlist add them they will be written to your custom mirror pool

    sudo pacman-mirrors –country Germany France Denmark

  • Create a mirrorlist with 5 mirrors up-to-date on your branch

    sudo pacman-mirrors –fastrack 5

  • I want to choose my mirrors

    sudo pacman-mirrors –interactive

  • I have a custom mirror list and I want to create a new custom mirror list?

    sudo pacman-mirrors –interactive –default

  • I have a custom mirror list - can I reset it?

    sudo pacman-mirrors –country all

I could pick one - fastrack → fasttrack

Other than that ?

the dashes. all the long form flags require 2; --

1 Like

hmm - must be something with the conversion from markdown to manpage

I have given the manpage an overhaul - perhaps there has been changes in pandoc - I have not noted.

I also generated a new manpage to see if I got it right - it seems I did.

1 Like

Manjaro has 2 packages in core repository that provide the files mentioned in OP data

packages.manjaro.org - pacman-mirrors

pacman-mirrors 4.24.1-2
pacman-mirrors-dev 5.0.2-2

If reinstalling pacman-mirrors does not help, I suggest install pacman-mirrors-dev to replace pacman-mirrors

I tried pacman mirrors-dev, still the same error:

sudo pacman-mirrors --continent
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 199, in check_internet_connection
    resp = requests.get(host, timeout=maxwait)
           ^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pacman-mirrors", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 148, in start
    app.run()
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 119, in run
    self.network = httpFn.check_internet_connection(tty=self.tty)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 202, in check_internet_connection
    except (requests.exceptions.ConnectionError,) as connError:

Returned back to pacman-mirrors, its intalllation ends with the same error. Trying the -f option gives the same errorr. Pretty much all of the help commands return the same error (only -G, -l, -lc, --status worked) .

I guess the only thing I could do is to disable to PGP keys from the conf file and update. Otherwise apparently the system doesn’t recognize the PGP keys and refuses to do anything. And this python error is rather strange. Python is working fine on my system.

>python --version
Python 3.12.3

>pacman-mirrors --version
Version 4.24.0

Error messages from pamac or pacman install would probably be more helpful than error messages from the packages installed with errors

Error messages from pamac or pacman should be in /var/log/pacman.log

[PACMAN] Running 'pacman -S pacman-mirrors'
[2024-06-12T11:59:41+0300] [ALPM] transaction started
[2024-06-12T11:59:41+0300] [ALPM] removed pacman-mirrors-dev (5.0.2-2)
[2024-06-12T11:59:41+0300] [ALPM] installed pacman-mirrors (4.24.1-2)
[2024-06-12T11:59:42+0300] [ALPM] transaction completed
[2024-06-12T11:59:42+0300] [ALPM] running '30-systemd-update.hook'...
[2024-06-12T11:59:42+0300] [ALPM] running '90-packagekit-refresh.hook'...
[2024-06-12T11:59:42+0300] [ALPM] running 'pacman-mirrors-install.hook'...
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] Your current config has been restored.
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] A new pacman-mirrors.conf is created as /etc/pacman-mirrors-new-20240612.conf
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] Please verify you're not missing any changes
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] Traceback (most recent call last):
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]   File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 227, in check_internet_connection
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]     resp = requests.get(host, timeout=maxwait)
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]            ^^^^^^^^^^^^
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] AttributeError: module 'requests' has no attribute 'get'
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] 
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] During handling of the above exception, another exception occurred:
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] 
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] Traceback (most recent call last):
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]   File "/usr/bin/pacman-mirrors", line 8, in <module>
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]     sys.exit(start())
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]              ^^^^^^^
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]   File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 127, in start
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]     app.run()
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]   File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 96, in run
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]     self.network = httpFn.check_internet_connection(tty=self.tty)
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]   File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 230, in check_internet_connection
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]     except (requests.exceptions.ConnectionError,) as connError:
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET]             ^^^^^^^^^^^^^^^^^^^
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] AttributeError: module 'requests' has no attribute 'exceptions'
[2024-06-12T11:59:42+0300] [ALPM-SCRIPTLET] hint: use `pacman-mirrors` to generate and update your pacman mirrorlist.

Apart from that I can use just pacman-mirrors:

sudo pacman-mirrors
Pacman-mirrors version 4.24.0
Local mirror status for stable branch
Mirror #1   OK  00:12   Germany      https://mirror.alpix.eu/manjaro/
Mirror #2   OK  02:04   Belgium      https://mirror.futureweb.be/manjaro/
Mirror #3   OK  02:22   Denmark      https://mirrors.dotsrc.org/manjaro/
Mirror #4   OK  05:52   Estonia      https://mirrors.xtom.ee/manjaro/
Mirror #5   OK  01:06   Spain        https://mirrors.ft.uam.es/manjaro/
Mirror #6   OK  01:05   Netherlands  https://mirror.bouwhuis.network/manjaro/
Mirror #7   --  13:33   Iran         https://repo.iut.ac.ir/repo/manjaro/
Mirror #8   OK  07:32   China        https://mirrors.jlu.edu.cn/manjaro/

but if I want to choose a specific country I get:

sudo pacman-mirrors -c Germany
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 227, in check_internet_connection
    resp = requests.get(host, timeout=maxwait)
           ^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pacman-mirrors", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 127, in start
    app.run()
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 96, in run
    self.network = httpFn.check_internet_connection(tty=self.tty)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 230, in check_internet_connection
    except (requests.exceptions.ConnectionError,) as connError:
            ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'exceptions'

this does not generate a new error in /var/log/pacman.log.

And did you install python-requests as advised in the second post?

Nope:

sudo pacman -S python-requests
решаване на зависимости...
търсене за конфликтни пакети...

Пакети (1) python-requests-2.32.3-1

Общ инсталиран размер:  0,60 MiB

:: Продължаване с инсталацията? [Y/n] y
(1/1) проверка на ключовете                                                                                           [#######################################################################] 100%
(1/1) проверка пакетна цялост                                                                                         [#######################################################################] 100%
грешка: python-requests: подписът от "Daniel M. Capella <polyzen@archlinux.org>" е с непознато доверие
:: Файл /var/cache/pacman/pkg/python-requests-2.32.3-1-any.pkg.tar.zst е повреден (невалиден или повреден пакет (PGP signature)).
Искате ли да го изтриете? [Y/n] n
грешка: неуспех в задаването на транзакцията (невалиден или повреден пакет (PGP signature))
Поява на грешки, няма обновени пакети.

ipx install requests
Note: Dependent package 'charset-normalizer' contains 1 apps
  - normalizer

No apps associated with package requests. Try again with '--include-deps' to include apps of dependent packages, which are listed above. If you are attempting to install a library, pipx should
not be used. Consider using pip or a similar tool instead.

pipx install requests --include-deps
⚠  Note: normalizer was already on your PATH at /usr/bin/normalizer
  installed package requests 2.32.3, installed using Python 3.12.3
  These apps are now globally available
    - normalizer
done! ✨ 🌟 ✨

and then when I try again

sudo pacman-mirrors -c Germany
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 227, in check_internet_connection
    resp = requests.get(host, timeout=maxwait)
           ^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pacman-mirrors", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 127, in start
    app.run()
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/pacman_mirrors.py", line 96, in run
    self.network = httpFn.check_internet_connection(tty=self.tty)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pacman_mirrors/functions/httpFn.py", line 230, in check_internet_connection
    except (requests.exceptions.ConnectionError,) as connError:
            ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'requests' has no attribute 'exceptions'

I find it very strange that something so important would come without its dependencies.

Also, my real issue is not with pacman-mirrors but with system failing to update or install anything due to “invalid or broken package (PGP signature)”.
I stumbled on this post when googling the PGP problem since I thought maybe my mirrors are old or something. Because it doesn’t recognise any PGP signature.

very strange. here module ‘requests’ installed but is not good (a bad module in home?)

what return LANG=C pip show requests

pip show requests
WARNING: Skipping /usr/lib/python3.12/site-packages/requests-2.32.2.dist-info due to invalid metadata entry 'name'
WARNING: Package(s) not found: requests

why i view this ???
pipx is only for Isolated Environments
run pacman-mirrors in isolated environment is not good.
if we install with pip/pipx, we break your config system

you use a bad “request” library in home or python venv

pip list --user | grep request  # return nothing or bad install
1 Like

Nah, my conda is deactivated, but ok, I did the crazy thing:

pip install requests --break-system-packages

and that gave few errors but installed. Now I can see the package:

pip list --user | grep request  
WARNING: Skipping /usr/lib/python3.12/site-packages/requests-2.32.2.dist-info due to invalid metadata entry 'name'
requests 2.32.3
WARNING: Skipping /usr/lib/python3.12/site-packages/requests-2.32.2.dist-info due to invalid metadata entry 'name'
WARNING: Skipping /usr/lib/python3.12/site-packages/requests-2.32.2.dist-info due to invalid metadata entry 'name'

without restarting, I still get the same error from “sudo pacman-mirrors -c Germany” (AttributeError: module ‘requests’ has no attribute ‘exceptions’).

But I cannot restart right now and usually python packages appear immediately after installed so it shouldn’t be the problem.

Also:

 LANG=C pip show requests
WARNING: Skipping /usr/lib/python3.12/site-packages/requests-2.32.2.dist-info due to invalid metadata entry 'name'
Name: requests
Version: 2.32.3
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache-2.0
Location: /home/denijane/.local/lib/python3.12/site-packages
Requires: certifi, charset-normalizer, idna, urllib3
Required-by: jupyterlab_server, pacman_mirrors, Sphinx

As the maintainer of pacman-mirrors - do not do that …

There is no reasons why default pacman-mirrors should not work.

If it does not you are in some kind of weird state - completely unsupported …

2 Likes