Hello ㅠ 코 To start coding as a hobby, I installed vcode and python through homebrew on iMac, and while I was studying various things, I checked that the random function was not imported.
import random random()
If you enter, the module object is not callable appears
import random print(random())
The output is the same when you type .
from math import random
If you enter , the output reads: /library/developer/CommandLineTools/Library/Frameworks/Python3.framework/Version/3.9/lib/python3.9/lib-dynload/math.cpython-39-darwin.so
I'd like to ask if there's any solution ㅠ<
module object is not callable
Module object cannot be called
That's the error message. If import is not possible, an import error or a ModuleNotFoundError will occur.
Now look at the example below and see why the error occurred in each case. Be sure to interpret and understand the meaning of the error message.
>>> from random import abcdef
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'abcdef' from 'random' (C:\PROGRAMS\Python31064\lib\random.py)
>>> import tandom
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tandom'
>>> a = "abc"
>>> a()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
>>> n = 3
>>> n()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
>>> import random
>>> random()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
>>> random.random()
0.7945498794154492
© 2024 OneMinuteCode. All rights reserved.