Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError:'module' object has no attribute 'call' :Python

Tags:

python

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'
like image 709
user Avatar asked Aug 12 '14 09:08

user


People also ask

How do I fix Python module has no attribute?

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.

Why am I getting AttributeError object has no attribute?

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 do you fix a module object is not callable?

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.

What does object has no attribute mean in Python?

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.


1 Answers

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

like image 162
Padraic Cunningham Avatar answered Oct 18 '22 04:10

Padraic Cunningham