Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package #11347

Closed
harmin-parra opened this issue Aug 24, 2023 · 5 comments
Closed
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@harmin-parra
Copy link

I am able to reproduce #10428

pytest 7.4.0

Reproduced on Linux Mint and on Fedora 37

pip3 list on Linux Mint:

Package                       Version             
----------------------------- --------------------
alabaster                     0.7.8               
apt-clone                     0.2.1               
apturl                        0.5.2               
arrow                         1.2.3               
asn1                          2.6.0               
attrs                         22.2.0              
Babel                         2.12.1              
bcrypt                        4.0.1               
beautifulsoup4                4.8.2               
binaryornot                   0.4.4               
bleach                        6.0.0               
blinker                       1.4                 
Brlapi                        0.7.0               
bsddb3                        6.2.7               
build                         0.10.0              
certifi                       2023.7.22           
cffi                          1.15.1              
chardet                       3.0.4               
charset-normalizer            3.2.0               
Click                         7.0                 
colorama                      0.4.3               
command-not-found             0.3                 
configobj                     5.0.6               
cookiecutter                  2.2.3               
cryptography                  41.0.1              
cupshelpers                   1.0                 
dbus-python                   1.2.16              
defer                         1.0.6               
distro                        1.4.0               
distro-info                   0.23ubuntu1         
docutils                      0.20.1              
entrypoints                   0.3                 
enum-compat                   0.0.3               
exceptiongroup                1.1.1               
flit                          3.9.0               
flit-core                     3.9.0               
grpcio                        1.16.1              
h11                           0.14.0              
html5lib                      1.0.1               
httplib2                      0.14.0              
idna                          2.8                 
ifaddr                        0.1.6               
imagesize                     1.4.1               
IMDbPY                        6.8                 
importlib-metadata            6.8.0               
importlib-resources           5.12.0              
iniconfig                     2.0.0               
Jinja2                        3.1.2               
jsonschema                    4.17.3              
keyring                       18.0.1              
launchpadlib                  1.10.13             
lazr.restfulclient            0.14.2              
lazr.uri                      1.0.3               
ldap3                         2.9.1               
louis                         3.12.0              
lxml                          4.5.0               
macaroonbakery                1.3.1               
Mako                          1.1.0               
Markdown                      3.1.1               
markdown-it-py                3.0.0               
MarkupSafe                    2.1.3               
mdurl                         0.1.2               
menulibre                     2.2.1               
meson                         0.53.2              
mutagen                       1.45.1              
mysqlclient                   1.4.4               
nemo-emblems                  5.2.0               
netaddr                       0.7.19              
netifaces                     0.10.4              
oauthlib                      3.1.0               
onboard                       1.4.1               
outcome                       1.2.0               
packaging                     23.1                
PAM                           0.4.2               
paramiko                      3.1.0               
pexpect                       4.6.0               
Pillow                        7.0.0               
pip                           20.0.2              
pkginfo                       1.9.6               
pkgutil-resolve-name          1.3.10              
pluggy                        1.0.0               
protobuf                      3.6.1               
psutil                        5.5.1               
puddletag                     2.0.1               
py                            1.11.0              
pyasn1                        0.4.8               
pycairo                       1.16.2              
pyclean                       2.7.0               
pycparser                     2.21                
pycrypto                      2.6.1               
pycups                        1.9.73              
pycurl                        7.43.0.2            
Pygments                      2.15.1              
PyGObject                     3.36.0              
PyICU                         2.4.2               
pyinotify                     0.9.6               
PyJWT                         1.7.1               
pymacaroons                   0.13.0              
PyNaCl                        1.5.0               
pyOpenSSL                     23.2.0              
pyparsing                     2.4.6               
pyparted                      3.11.2              
pyproject-hooks               1.0.0               
PyQt5                         5.14.1              
pyRFC3339                     1.1                 
pyrsistent                    0.19.3              
pysftp                        0.2.9               
PySocks                       1.7.1               
pytest                        7.4.0               
pytest-html                   3.2.0               
pytest-metadata               3.0.0               
python-apt                    2.0.1+ubuntu0.20.4.1
python-dateutil               2.8.2               
python-debian                 0.1.36+ubuntu1.1    
python-Levenshtein            0.12.0              
python-magic                  0.4.16              
python-slugify                8.0.1               
python-xapp                   2.2.1               
python-xlib                   0.23                
pythondialog                  3.4.0               
pytz                          2019.3              
pyxdg                         0.26                
PyYAML                        5.3.1               
qrcode                        6.1                 
readme-renderer               40.0                
reportlab                     3.5.34              
requests                      2.31.0              
requests-file                 1.4.3               
requests-toolbelt             1.0.0               
requests-unixsocket           0.2.0               
rfc3986                       2.0.0               
rich                          13.5.0              
roman                         2.0.0               
SecretStorage                 2.3.1               
selenium                      4.11.0              
setproctitle                  1.1.10              
setuptools                    45.2.0              
simplejson                    3.16.0              
sip                           4.19.21             
six                           1.14.0              
sniffio                       1.3.0               
snowballstemmer               2.2.0               
sortedcontainers              2.4.0               
soupsieve                     1.9.5               
sphinx                        7.1.2               
sphinxcontrib-applehelp       1.0.4               
sphinxcontrib-devhelp         1.0.2               
sphinxcontrib-htmlhelp        2.0.1               
sphinxcontrib-jsmath          1.0.1               
sphinxcontrib-qthelp          1.0.3               
sphinxcontrib-serializinghtml 1.1.5               
systemd-python                234                 
text-unidecode                1.3                 
tinycss2                      1.0.2               
tldextract                    2.2.1               
tomli                         2.0.1               
tomli-w                       1.0.0               
tqdm                          4.65.0              
trio                          0.22.2              
trio-websocket                0.10.3              
twine                         4.0.2               
typing-extensions             4.7.1               
ubuntu-advantage-tools        8001                
ubuntu-drivers-common         0.0.0               
ufw                           0.36                
Unidecode                     1.1.1               
urllib3                       2.0.4               
vboxapi                       1.0                 
wadllib                       1.3.3               
webencodings                  0.5.1               
wheel                         0.34.2              
wsproto                       1.2.0               
xkit                          0.0.0               
xlrd                          1.1.0               
youtube-dl                    2021.4.26           
zipp                          3.15.0 
  • [ X ] a detailed description of the bug or problem you are having
  • [ X ] output of pip list from the virtual environment you are using
  • [ X ] pytest and operating system versions
  • [ X ] minimal example if possible
@The-Compiler
Copy link
Member

That issue shows a stacktrace of a pytest-html version that's older than what you have, so I doubt you see that exact issue (which isn't a pytest issue anyways). Please show the exact full output you're getting.

@The-Compiler The-Compiler added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Aug 24, 2023
@harmin-parra
Copy link
Author

$ pytest --help
Traceback (most recent call last):
  File "/home/harmin/.local/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 189, in console_main
    code = main()
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 147, in main
    config = _prepareconfig(args, plugins)
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 328, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 55, in _multicall
    gen.send(outcome)
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/helpconfig.py", line 103, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1075, in pytest_cmdline_parse
    self.parse(args)
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1425, in parse
    self._preparse(args, addopts=addopts)
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1305, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "/usr/local/lib/python3.8/dist-packages/pytest_html/plugin.py", line 9, in <module>
    from .html_report import HTMLReport
  File "/home/harmin/.local/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "/usr/local/lib/python3.8/dist-packages/pytest_html/html_report.py", line 11, in <module>
    from py.xml import html
ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package

@RonnyPfannschmidt
Copy link
Member

This looks like the old distro package is breaking the user installed newer version

I recommend using virtualenv to protect yourself from distro breakage

@harmin-parra
Copy link
Author

It works fine with venv

By the way, how do I deactivate a venv ?

@The-Compiler
Copy link
Member

By using deactivate, or you might want to consider just calling the tools inside the virtualenv folder without activation (e.g. .venv/bin/pytest). As an introduction, I can recommend Python Virtual Environments in Five Minutes | Chris Warrick.

agoscinski added a commit to osscar-org/scicode-widgets that referenced this issue Sep 4, 2023
when installing pytest 3.4.1 pytes-html is downgraded
pytest-dev/pytest#11347 (comment)
agoscinski added a commit to osscar-org/scicode-widgets that referenced this issue Sep 4, 2023
when installing pytest 3.4.1 pytes-html is downgraded
pytest-dev/pytest#11347 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants