Python module and import appear importerror:no module named ' xxx ' problem

Source: Internet
Author: User

First of all, this is the problem I developed with pycharm4.5, and I'm doing the Python module and function unit example.
Need to build a module named MyModule.
So I wrote one, it's pretty simple.

def  arithmetic   (X=1 , Y=1 , operator= ) :  result={ "+" : X+y, Span class= "hljs-string" "-" : X-y,  "*" : x*y,  "/" : X/y} return  result.get (operator) class  myclass :  < Span class= "Hljs-keyword" >def  myfunc   (self) :  print  ( "MyModule.MyClass.myFunc ()" 
     )  

And then you write a class to call the class that you just

import myModuleif"__main__":    mathResult = myModule.arithmetic(2,2,"*")    "the math result is :%f" % mathResult    print (format)    myClass = myModule.MyClass()    myClass.myFunc()

Okay, here's the question, so write it, execute the second program, and the result is wrong.
So very simple, according to experience, I refer to the following link
[Python module and import appear importerror:no module named ' xxx ' problem] (http://blog.csdn.net/damotiansheng/article/details/43916881)
Don't say that, it's very helpful. But it's useless.
I have done all the methods I have just linked, and I can't solve this problem by tossing and turning. Placed for 3 days, and suddenly one day I realized it.
See.

If you want to call, you have to ensure that the two files in the project directory, I put them in the basic package, as for why the package can not be put, I still do not understand.
In short, this also solves a big problem.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Python module and import appear importerror:no module named ' xxx ' problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.