2

Henlo everyone,

I met a very specific problem with my Python installation. I have a PyCharm project using a venv with pywikibot installed. Whenever I try to import the module, I get the following error:

Traceback (most recent call last):
  File "C:/Users/<username>/<path to project>/alphabets/coptic_characters.py", line 1, in <module>
    import pywikibot as pwb
  File "C:\Users\<username>\<path to project>\venv\lib\site-packages\pywikibot\__init__.py", line 15, in <module>
    from decimal import Decimal
  File "C:\Users\<username>\Anaconda3\lib\decimal.py", line 3, in <module>
    from _decimal import *
AttributeError: module 'numbers' has no attribute 'Number'

It appears to have broken itself because earlier in the day it worked with no problems.

I also have the module installed on a global Anaconda3 setup elsewhere in my computer. It works fine everywhere except, that's where it gets weird, when I try to execute it inside the project directory. It gets even stranger than that, if I execute the interpreter in a sub-folder, it works again. I don't understand what's happening here at all…

I tried creating a new project but I get the same error and behavior.

What am I missing? I don't understand why it stopped working suddenly event though I did nothing to the venv.

P.S.: I'm on Windows 10.

Damia
  • 141
  • 1
  • 9
  • 2
    maybe you have file with name `numbers.py` so now code import your file instead of module `numbers`. You can check which file is loaded `import numbers` `print( numbers.__file__ )` – furas Jul 28 '19 at 09:42
  • omg, that was it… I had created a package named `numbers` inside the project. I never would have thought that a module I created could overwrite code from a package… What a relief ! – Damia Jul 28 '19 at 09:50

1 Answers1

3

So !

It appears that a module I created with the name numbers was interfering with Python's code. I just changed the name and it suddenly worked again !

Thanks to @furas for suggesting this.

Damia
  • 141
  • 1
  • 9