Freezed package are not found in pypi

I have made a requirement file – many of package are not found in pypi ,but I found these packages are almost apt packages ,why I get such a requirement file

Not everything is on PyPI, although anything stable enough to distribute
with apt really should be.

How did you construct your requirements file? Can you show some of the
lines which are not found? Can you show us a transcript of your pip
command and its output which shows failure?

Please paste these inline as text in your reply, not as screenshot
images.

Cheers,
Cameron Simpson cs@cskk.id.au

this is how i make a requirement

pip freeze > requirement  

output is below :

Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.doubanio.com/simple/indicator-sound-switcher/

After that ,I searched indicator-sound-switcher . it shows that its a apt package about sound.
no matter how the pip freeze works, is there a way to solve this problem ? I find many packages facing the same situation

You’re seeing Python packages installed and managed by apt. pip can’t find some of the packages, because they are from apt’s DPKG repository, not from PyPI.

This is really a symptom of a workflow issue though – it is generally recommended to not work directly with the system/OS-provided Python, and to instead use a virtual environment (from venv or virtualenv). It is also, a reasonable idea to compile your own Python, using tools like pyenv, and use virtual environments as well.

1 Like

this is how i make a requirement

pip freeze > requirement

That looks ok.

output is below :

Exception:
Traceback (most recent call last):
 File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
   status = self.run(options, args)
 File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
   wb.build(autobuilding=True)
 File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
   self.requirement_set.prepare_files(self.finder)
 File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
   ignore_dependencies=self.ignore_dependencies))
 File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
   require_hashes
 File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
   self.link = finder.find_requirement(self, upgrade)
 File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
   all_candidates = self.find_all_candidates(req.name)
 File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
   for page in self._get_pages(url_locations, project_name):
 File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
   page = self._get_page(location)
 File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
   return HTMLPage.get_page(link, session=self.session)
 File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
   resp.raise_for_status()
 File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
   raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.doubanio.com/simple/indicator-sound-switcher/

After that ,I searched indicator-sound-switcher . it shows that its a apt package about sound.

Hmm, indeed it does not exist. Looking up a level (drop the trailing
“indicator-sound-switcher/”) shows a heap of stuff but not that package.

[ I apologise for the obtuseness, discourse rejects posts with more than
some tiny number of URLs in them, so I’m avoiding reciting full URLs. ]

no matter how the pip freeze works, is there a way to solve this
problem ? I find many packages facing the same situation

That’s very annoying.

1: Have you checked you have the most modern pip? I’m surprised it fails
in the way above - I would normally expect a more polite failure.

2: Maybe the requirements file is providing a full URL though - is there
a line with “indicator-sound-switcher” in the requirements file? What
does that line look like?

3: Usually we go the other way: instead of using pip freeze we just put
the specific packages we need to use in a requirements file. Then pip
fetches just those for us and also their dependencies. Have you tried
making a requirements file by hand with just a few things in it?

4: Usually “pip freeze” is to aid reproducing exactly the same
environment in anthoer python install. For example, when building some
software distribution which exactly matches the package versions your
tested with. What was your objective when using “pip freeze”?

Cheers,
Cameron Simpson cs@cskk.id.au

As @pradyunsg noted, indicator-sound-switcher appears to be a Debian-specific Python package, that is installed via an apt package but not published on PyPI.

Pip can’t know that - all it sees is that you’re freezing an environment containing that package, so it records the package name in your requirements file. It’s up to you to make the source of that package available to pip, if you expect to pip install from that requirements file. As Debian don’t publish that package on PyPI, you can’t easily do that.

Your options are basically:

  1. Hand-edit the requirements file to remove the non-PyPI packages, and install them by some other means when building a new environment.
  2. Use a virtual environment, so that you are freezing an environment that contains only what you need to build your project, and not everything that you’ve got installed in your system Python.
2 Likes

Actually, looking at the output of pip3 freeze on a new Ubuntu system, I’d say just never use the system Python on Ubuntu at all - it’s full of all sorts of stuff that you should never be assuming is present by default. Unfortunately, you can’t just use virtual environments out of the box on Ubuntu either, you need to install the python3-venv package to make them work.

Sigh.

4 Likes