DidYouMean-Python icon indicating copy to clipboard operation
DidYouMean-Python copied to clipboard

Can't use from `pip` install

Open FedeClaudi opened this issue 5 years ago • 4 comments

Hi,

very cool package! I'm trying to integrate it with pyinspect to complement pyinspect's fancy tracebacks with your helpful messages, but I can't get didyoumean to work. I've tried both with pip install BetterErrorMessages and by installing from the master branch on github, but it's the same.

I think that's in an issue about how modules are imported within the package, e.g.

from didyoumean.didyoumean_internal import add_suggestions_to_exception

results in:

ModuleNotFoundError: No module named 'didyoumean_re'

and

import didyoumean
didyoumean.didyoumean_api.didyoumean_postmortem()

results in:

AttributeError: module 'didyoumean' has no attribute 'didyoumean_api'

and so on..

FedeClaudi avatar Oct 31 '20 10:10 FedeClaudi

I think that the problem is related to what's discussed in this PR: https://github.com/SylvainDe/DidYouMean-Python/pull/35

FedeClaudi avatar Oct 31 '20 10:10 FedeClaudi

I also think #50 would fix it.

I work around this in futurecoder with this:

import pygments  # can be any other pip installed module
site_packages = strip_required_suffix(pygments.__file__, "pygments/__init__.py")
sys.path.append(site_packages + "didyoumean/")
import didyoumean

alexmojaki avatar Oct 31 '20 11:10 alexmojaki

Thanks for the report ! I must confess that I am still haven't understood everything about making things pip usable... I'll try some things locally based on https://github.com/SylvainDe/DidYouMean-Python/pull/50 asap.

SylvainDe avatar Oct 31 '20 22:10 SylvainDe

Thanks @alexmojaki , I didn't know you could do that. It's not very clean though, better to fix the path in the first place. I've opened a PR for that: https://github.com/SylvainDe/DidYouMean-Python/pull/53

FedeClaudi avatar Nov 01 '20 09:11 FedeClaudi