Module object has no attribute - PyCharm Error, command line is ok

Hello,

I am getting the classic 'module' object has no attribute "module" error in PyCharm. It must be a setting in PyCharm as I can:

1. Run the script from a command shell when navigating to the folder:

2. Run the script in PyCharm *if* and only if I have "Add content roots to PYTHONPATH" unchecked.

3. However, if I have "Add Content roots to PYTHONPATH" checked, I receive the following error:

I am fairly new to Python, and I am interpreting this as saying that there is no 'py_version' function (class?) in the API module.

Here is my project structure and code snippit:

 

Can someone kindly explain what is happening and why in the command shell it will detect the adapter and in PyCharm is will not detect the adapter if I have "Add Content roots to PYTHONPATH" checked?

I am glad that I can get it to work in PyCharm, but I would like to understand why.

Thanks.

1 comment

Hi,

This might be a long shot, but the first thing I would check is if you have any object named 'module' defined anywhere in your code? It's possible that you're running into naming conflict with Python's inbuilt object, where modifying PYTHONPATH can cause your module take priority over inbuilt module.

0

Please sign in to leave a comment.