推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
lukeshawn
V2EX  ›  Python

from abstest import my_abs 的时候失败

  •  
  •   lukeshawn · Apr 17, 2018 · 3383 views
    This topic created in 2952 days ago, the information mentioned may be changed or developed.
    自定义 my_abs 函数的文件后保存成 abstest 的 py 文件(名字没有.py )
    然后在交互模式下输入 from abstest import my_abs
    显示
    ModuleNotFoundError: No module named 'abstest'
    求大神解答
    11 replies    2018-04-20 21:58:44 +08:00
    SingeeKing
        1
    SingeeKing  
    PRO
       Apr 17, 2018
    我猜你这个文件的文件名叫 abstest
    tempdban
        2
    tempdban  
       Apr 17, 2018
    名字没有.py 是啥操作
    lukeshawn
        3
    lukeshawn  
    OP
       Apr 18, 2018
    @SingeeKing 是的,可是加了.py 也没有用
    lukeshawn
        4
    lukeshawn  
    OP
       Apr 18, 2018
    @tempdban 加了.py 也没有用
    lukeshawn
        5
    lukeshawn  
    OP
       Apr 18, 2018
    @SingeeKing 求大神指点,一直显示:ModuleNotFoundError: No module named 'abstest'
    SingeeKing
        6
    SingeeKing  
    PRO
       Apr 18, 2018 via iPad
    @lukeshawn 你执行这个语句的文件改个名
    SingeeKing
        7
    SingeeKing  
    PRO
       Apr 18, 2018 via iPad
    哦不,bash 所在文件夹
    lukeshawn
        8
    lukeshawn  
    OP
       Apr 18, 2018
    @SingeeKing 什么是 bash 所在文件夹,我已经把保存的文件名加了.py ,可是还是显示 No module named 'abstest'
    tempdban
        9
    tempdban  
       Apr 19, 2018
    你这要指点的可就多了,楼上的大哥提示你了,执行 python 命令之前,先 cd 到放 abstest.py 文件的那个目录
    lukeshawn
        10
    lukeshawn  
    OP
       Apr 20, 2018
    @SingeeKing
    @tempdban
    cd 之后显示 Not a directory
    lukeshawn
        11
    lukeshawn  
    OP
       Apr 20, 2018
    @tempdban
    @SingeeKing
    按照你们的方法成功了,谢谢你们照顾我这个新人哈。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1141 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:33 · PVG 07:33 · LAX 16:33 · JFK 19:33
    ♥ Do have faith in what you're doing.