I'm getting a very strange error message when I run a python module. The interpreter will not even run the first lines of my code but will immediately do some sort of python test which fails. Here is the full trackback
Traceback (most recent call last):
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 "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/pytest/__init__.py", line 5, in <module>
from _pytest.assertion import register_assert_rewrite
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/_pytest/assertion/__init__.py", line 9, in <module>
from _pytest.assertion import rewrite
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 34, in <module>
from _pytest.assertion import util
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/_pytest/assertion/util.py", line 13, in <module>
import _pytest._code
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/_pytest/_code/__init__.py", line 2, in <module>
from .code import Code
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/_pytest/_code/code.py", line 33, in <module>
import pluggy
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/pluggy/__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/pluggy/manager.py", line 6, in <module>
import importlib_metadata
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 466, in <module>
__version__ = version(__name__)
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 433, in version
return distribution(package).version
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 406, in distribution
return Distribution.from_name(package)
File "/Users/kylefoley/Documents/codes/venv3/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 175, in from_name
dists = resolver(name)
File "<frozen importlib._bootstrap_external>", line 1382, in find_distributions
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/metadata.py", line 379, in find_distributions
found = cls._search_paths(context.pattern, context.path)
AttributeError: 'str' object has no attribute 'pattern'
Here is the actual method that is failing:
class MetadataPathFinder(DistributionFinder):
@classmethod
def find_distributions(cls, context=DistributionFinder.Context()):
"""
Find distributions.
Return an iterable of all Distribution instances capable of
loading the metadata for packages matching ``context.name``
(or all names if ``None`` indicated) along the paths in the list
of directories ``context.path``.
"""
found = cls._search_paths(context.pattern, context.path)
return map(PathDistribution, found)
I have two modules, both begin with the exact same two lines of code which are
import copy
import sys
One of the module works the other does not. The strange part is that on the failing module the first two lines of code do not every run. Further, I'm using Pycharm and there are no flags on the module that is not working.
contextparameter. Can you send the code you wrote? Where have you used that method?