Python Forum

Full Version: Module import error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello All. Trying to load a module into python 3, it keeps giving me error:
__
>>> import chaos
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import chaos
ModuleNotFoundError: No module named 'chaos'
__

I'm using a Mac and not sure if I'm saving it in the incorrect location?
Module contains:
def main():
print("This is an illustration of a chaotic fucntion")
x = eval(input("enter a number between 0 and 1: "))
for i in range(10):
x = 3.9 * x * (1-x)
print(x)

main()

Any help here much appreciated
It is working perfectly on window 7 and python 3.6.2.
def main():
    print("This is an illustration of a chaotic function")
    x = eval(input("enter a number between 0 and 1: "))
    print(type(x))
    for i in range(10):
        x = 3.9 * x * (1-x)
    print("The value of chaotic function is ",x)
main()
First of all, please insert your code and your output inside respective tags.
Secondly when you write
import chaos
the name of the file in which choas code is written should be chaos.py
and it should be inside the current directory (from which you are importing the module).

If you could not place the chaos.py inside the current directory then you could update the system path, which is by default set to current directory in your code from which you are importing the chaos module.