Python Forum
Module import error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Module import error (/thread-4994.html)



Module import error - CoolSchoolBoy - Sep-14-2017

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


RE: Module import error - rajeev1729 - Sep-14-2017

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()



RE: Module import error - Sagar - Sep-14-2017

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.