I am new to python and not knowing whats going on here. I have tried searching a lot but had to end up asking here
I am trying to learn subprocess which executes a simple command as:
import subprocess
subprocess.call(['ls'])
Now, when I run the program I get this error:
Traceback (most recent call last):
File "subprocess.py", line 1, in <module>
import subprocess
File "/task/subprocess.py", line 2, in <module>
subprocess.call(['ls'])
AttributeError: 'module' object has no attribute 'call'
To solve the Python "AttributeError: module has no attribute", make sure you haven't named your local modules with names of remote modules, e.g. datetime.py or requests.py and remove any circular dependencies in import statements.
If you are getting an object that has no attribute error then the reason behind it is because your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt to verify.
How to fix typeerror: 'module' object is not callable? To fix this error, we need to change the import statement in “mycode.py” file and specify a specific function in our import statement.
It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling.
You called your file subprocess.py
, change then name and you will be ok. You are trying to import from your file and not the module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With