Import own .py files in anaconda spyder

后端 未结 5 1668
梦毁少年i
梦毁少年i 2021-02-14 16:21

I\'ve written my own mail.py module in spider (anaconda). I want to import this py file in other python (spider) files just by \'import mail\'

I searched on the internet

5条回答
  •  佛祖请我去吃肉
    2021-02-14 16:56

    I did a slightly different solution approach that is less sophisticated. When I start my anaconda terminal it is at a C prompt. I just did a cd d:\mypython\lib in the beginning window before starting python. once I did that I could simply just import my own classes that I put in that library with "import MyClass as my" then I was off and running. It is interesting, I did 2 days of internet searching in my part time and could not find the answer either, until I asked a friend.

    cd d:\mypython\lib
    python
    >>> import MyClass as my
    >>> my1=my.MyClass()
    >>> my1.doSomething() 
    

    worked for me on my anaconda / windows 10 environment python 3.6.6.

提交回复
热议问题