question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Windows] Unable to inject jaraco.clipboard

See original GitHub issue

Describe the bug Today I’m upgrading my Python 3.8 envs with Python 3.9. reinstall-all failed (found executables missing), so I uninstalled manually and attempted to reinstall. After pipx install 'xonsh[ptk]', I attempted to inject two deps:

PS C:\WINDOWS\system32> pipx inject xonsh jaraco.clipboard
Internal error with venv metadata inspection.
Unable to install jaraco-clipboard.
Check the name or spec for errors, and verify that it can be installed with pip.
←[?25h
PS C:\WINDOWS\system32> pipx inject xonsh keyring
  injected package keyring into venv xonsh
done!
←[?25h

With --verbose:

PS C:\WINDOWS\system32> pipx inject --verbose xonsh jaraco.clipboard
←[?25lpipx > (setup:567): pipx version is 0.15.6.0
pipx > (setup:568): Default python interpreter is 'c:\\program files\\python39\\python.exe'
pipx > (run_pipx_command:135): Virtual Environment location is C:\Users\jaraco\.local\pipx\venvs\xonsh
pipx > (needs_upgrade:54): Time since last upgrade of shared libs, in seconds: 238598.75953483582. Upgrade will be run by pipx if greater than 2592000.0.
pipx > (package_name_from_spec:247): Determined package name: jaraco-clipboard
pipx > (package_name_from_spec:248): Package name determined in 0.0s
pipx > (_parsed_package_to_package_or_url:127): cleaned package spec: jaraco-clipboard
installing jaraco-clipboard...
pipx > (run_subprocess:113): running C:\Users\jaraco\.local\pipx\venvs\xonsh\Scripts\python.exe -m pip install jaraco-clipboard
Requirement already satisfied: jaraco-clipboard in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (2.0.1)
Requirement already satisfied: jaraco.windows>=3.4; sys_platform == "win32" in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco-clipboard) (5.0.0)
Requirement already satisfied: six in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (1.15.0)
Requirement already satisfied: jaraco.text in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (3.2.0)
Requirement already satisfied: jaraco.ui in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (2.0.1)
Requirement already satisfied: jaraco.collections in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (3.0.0)
Requirement already satisfied: path.py>=6.2 in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (12.5.0)
Requirement already satisfied: jaraco.structures>=1.1.1 in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (2.0)
Requirement already satisfied: more-itertools in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (8.5.0)
Requirement already satisfied: jaraco.functools in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.text->jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (3.0.1)
Requirement already satisfied: jaraco.classes in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from jaraco.ui->jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (3.1.0)
Requirement already satisfied: path in c:\users\jaraco\.local\pipx\venvs\xonsh\lib\site-packages (from path.py>=6.2->jaraco.windows>=3.4; sys_platform == "win32"->jaraco-clipboard) (15.0.0)
pipx > (run_subprocess:113): running C:\Users\jaraco\.local\pipx\venvs\xonsh\Scripts\python.exe -c <contents of venv_metadata_inspector.py> jaraco-clipboard C:\Users\jaraco\.local\pipx\venvs\xonsh\Scripts
pipx > (get_venv_metadata_for_package:282): Internal error with venv metadata inspection.
pipx > (get_venv_metadata_for_package:283): venv_metadata_inspector.py Traceback:
Traceback (most recent call last):
  File "<string>", line 159, in <module>
  File "<string>", line 120, in main
  File "<string>", line 37, in get_apps
  File "C:\Users\jaraco\.local\pipx\shared\Lib\site-packages\pkg_resources\__init__.py", line 465, in get_distribution
    dist = get_provider(dist)
  File "C:\Users\jaraco\.local\pipx\shared\Lib\site-packages\pkg_resources\__init__.py", line 341, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "C:\Users\jaraco\.local\pipx\shared\Lib\site-packages\pkg_resources\__init__.py", line 884, in require
    needed = self.resolve(parse_requirements(requirements))
  File "C:\Users\jaraco\.local\pipx\shared\Lib\site-packages\pkg_resources\__init__.py", line 770, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jaraco-clipboard' distribution was not found and is required by the application
pipx > (_parsed_package_to_package_or_url:127): cleaned package spec: jaraco-clipboard
Unable to install jaraco-clipboard.
Check the name or spec for errors, and verify that it can be installed with pip.
←[?25h

Expected behavior The package should have installed correctly.

It looks like the problem is the manglingnormalization of the name. The package name is jaraco.clipboard not jaraco-clipboard:

PS C:\WINDOWS\system32> pip-run jaraco-clipboard
Collecting jaraco-clipboard
  Using cached jaraco.clipboard-2.0.1-py2.py3-none-any.whl (4.6 kB)
Collecting jaraco.windows>=3.4; sys_platform == "win32"
  Using cached jaraco.windows-5.0.0-py3-none-any.whl (54 kB)
Collecting jaraco.text
  Using cached jaraco.text-3.2.0-py2.py3-none-any.whl (8.1 kB)
Collecting more-itertools
  Using cached more_itertools-8.5.0-py3-none-any.whl (44 kB)
Collecting jaraco.collections
  Using cached jaraco.collections-3.0.0-py2.py3-none-any.whl (9.4 kB)
Collecting jaraco.ui
  Using cached jaraco.ui-2.0.1-py2.py3-none-any.whl (7.5 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting path.py>=6.2
  Using cached path.py-12.5.0-py3-none-any.whl (2.3 kB)
Collecting jaraco.structures>=1.1.1
  Using cached jaraco.structures-2.0-py2.py3-none-any.whl (4.3 kB)
Collecting jaraco.functools
  Using cached jaraco.functools-3.0.1-py3-none-any.whl (6.7 kB)
Collecting jaraco.classes
  Using cached jaraco.classes-3.1.0-py2.py3-none-any.whl (5.7 kB)
Collecting path
  Using cached path-15.0.0-py3-none-any.whl (21 kB)
Installing collected packages: six, more-itertools, jaraco.functools, jaraco.text, jaraco.classes, jaraco.collections, jaraco.ui, path, path.py, jaraco.structures, jaraco.windows, jaraco-clipboard
Successfully installed jaraco-clipboard jaraco.classes-3.1.0 jaraco.collections-3.0.0 jaraco.functools-3.0.1 jaraco.structures-2.0 jaraco.text-3.2.0 jaraco.ui-2.0.1 jaraco.windows-5.0.0 more-itertools-8.5.0 path-15.0.0 path.py-12.5.0 six-1.15.0
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources.get_distribution('jaraco-clipboard')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 480, in get_distribution
    dist = get_provider(dist)
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 356, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 899, in require
    needed = self.resolve(parse_requirements(requirements))
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 785, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jaraco-clipboard' distribution was not found and is required by the application
>>> pkg_resources.get_distribution('jaraco.clipboard')
jaraco.clipboard 2.0.1 (c:\users\jaraco\appdata\local\temp\pip-run-ir9ktr_4)
>>>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
itsayellowcommented, Oct 24, 2020

I think I have a venv_metadata_inspector.py version that doesn’t use pkg_resources that seems to work across all tests on all platforms.

I just started with @jaraco 's #344 and made a few changes. I think it works really well. I’m doing a lot of metadata debugging to make sure it’s giving proper metadata, and it looks good.

I’ll probably wait to make it the only change in a pipx version since it’s such a core part of pipx.

1reaction
uranusjrcommented, Oct 21, 2020

The problem right now is we’re using setuptools’s get_distribution to find a distribution matching the name, and that function does not correctly find a package from a normalised name. So we should not use it.

pip uses a lower-level construct, pkg_resources.WorkingSet, to build the distribution mapping with correct name normalisation: https://github.com/pypa/pip/blob/08c99b6e00135ca8df2e98db58aa0b701b971c64/src/pip/_internal/utils/misc.py#L421-L537

Alternatively, Python 3.8+ includes importlib.metadata.distribution(), which correctly implements PEP 503 logic. The same implementation is also available as importlib-metadata on PyPI for earlier Python 3 versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I copy a string to the clipboard? - python
r.update() # now it stays on the clipboard after the window is closed ... Then I got a new computer with Windows 10...
Read more >
jaraco.windows 3.1.2 - PyPI
Fixed regression in clipboard module. Restored changes from 2.16, unintentionally omitted from 3.0. 3.0. Moved many of the API definitions to the jaraco....
Read more >
how to fix clipboard when it does not copy and paste
Also I downloaded a program called Logmein tried to uninstall it but cannot. I uninstalled it through Add/Remove Programs and tried through ...
Read more >
How to copy HTML code to clipboard using Python?
Then, try paste the clipboard (ctrl+v) in microsoft word or other local that ... err.winerror == 0: # open failure pass else: print(...
Read more >
The Tidelift catalog of open source packages
It detects the window being resized and updates the co-ordinates of the image map. ... Add-on module to support JSR-310 (Java 8 Date...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found