swansonk14 / typed-argument-parser

Typed argument parser for Python
MIT License
494 stars 40 forks source link

ImportError: cannot import name 'Tap' from 'tap' #124

Closed ayushnoori closed 8 months ago

ayushnoori commented 9 months ago

Hi Kyle, wanted to let you know that, even after installing Tap using pip install typed-argument-parser, I am still encountering the following error:

ImportError: cannot import name 'Tap' from 'tap'

I'm using an M2 Mac inside a virtualenv virtual environment. A similar or same issue was already reported elsewhere: https://github.com/MehdiAbbanaBennani/continual-learning-ogdplus/issues/9, and an external website was linked there which may provide more information about the problem.

martinjm97 commented 9 months ago

Hi @ayushnoori,

Thank you for your interest in Tap!

The user in that link ran pip install tap rather than pip install typed-argument-parser. If you ran pip install typed-argument-parser then the issue that you face is different.

The only way I could reproduce your error (ImportError) was by having a file called tap.py in the same directory as the Python script and then running from tap import Tap.

If you don't have a tap.py file in the same folder and tap is not installed, you get ModuleNotFoundError: No module named 'tap' instead.

I recommend removing or renaming any file in the same directory with the name tap.py then trying again.

Best, Jesse

swansonk14 commented 8 months ago

Hi @ayushnoori,

Thanks for sharing that issue! I hope Jesse's answer solved your problem, but please let us know if you're still having any issues.

Best, Kyle

ayushnoori commented 8 months ago

Thanks, @martinjm97 and @swansonk14. I couldn't find tap.py in the same directory – perhaps I created and deleted this file by mistake. I recreated the virtual environment and this seemed to solve the issue. Looks like this is resolved, will let you know if I run into this issue again.