[New-bugs-announce] [issue44132] Local import conflict with system import

Oscar report at bugs.python.org
Fri May 14 11:39:20 EDT 2021

New submission from Oscar <Oscar.Trejo-Soria at digital.ai>:

Not sure if this is the right place to post this, but I stumble upon the following error.

I have the following directory structure

$ tree /F
Folder PATH listing
Volume serial number is C0000100 B8C8:3DC4
│   requirements.txt
│   run_repro.bat
    │   jira_utils.py
    │   main.py
    │   __init__.py

and I am getting the following error when I run 

(venv) > C:\depot\bitbucket\python_bug
$ python testdriver\main.py
Traceback (most recent call last):
  File "testdriver\main.py", line 1, in <module>
    from testdriver.jira_utils import JiraUtils
  File "C:\depot\bitbucket\python_bug\testdriver\jira_utils.py", line 1, in <module>
    from jira import JIRA, JIRAError
  File "C:\depot\bitbucket\python_bug\venv\lib\site-packages\jira\__init__.py", line 10, in <module>
    from jira.client import JIRA  # noqa: E402
  File "C:\depot\bitbucket\python_bug\venv\lib\site-packages\jira\client.py", line 29, in <module>
    from pkg_resources import parse_version
  File "C:\depot\bitbucket\python_bug\venv\lib\site-packages\pkg_resources\__init__.py", line 32, in <module>
    import plistlib
  File "C:\Python37\Lib\plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
ModuleNotFoundError: No module named 'xml.parsers'

but if I run 
(venv) otrejoso at OTREJOSO-TLALOC C:\depot\bitbucket\python_bug
$ python -c "from testdriver.jira_utils import JiraUtils"

(venv) otrejoso at OTREJOSO-TLALOC C:\depot\bitbucket\python_bug

There is no error.

I wonder if this is some kind of bug with importing packages or is it a way to fix this by importing differently?

I have attached a zip file that should be able to repro the issue. It is pretty simple since it just imports packages.
There is a run_repro.bat script to make things easier to repro

Steps of bat script:
python testdriver\main.py
python -c "from testdriver.jira_utils import JiraUtils"

Note: the zip contains the minimal files that showed the issue on bigger scale project that we have.

Thanks in advance.

files: error.zip
messages: 393669
nosy: otrejoso
priority: normal
severity: normal
status: open
title: Local import conflict with system import
versions: Python 3.7
Added file: https://bugs.python.org/file50042/error.zip

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list