V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-04-17 12:18:56 +08:00 · 2528 次点击
    这是一个创建于 2172 天前的主题,其中的信息可能已经有所发展或是发生改变。
    自定义 my_abs 函数的文件后保存成 abstest 的 py 文件(名字没有.py )
    然后在交互模式下输入 from abstest import my_abs
    显示
    ModuleNotFoundError: No module named 'abstest'
    求大神解答
    11 条回复    2018-04-20 21:58:44 +08:00
    SingeeKing
        1
    SingeeKing  
       2018-04-17 14:12:24 +08:00
    我猜你这个文件的文件名叫 abstest
    tempdban
        2
    tempdban  
       2018-04-17 14:15:46 +08:00
    名字没有.py 是啥操作
    lukeshawn
        3
    lukeshawn  
    OP
       2018-04-18 11:32:43 +08:00
    @SingeeKing 是的,可是加了.py 也没有用
    lukeshawn
        4
    lukeshawn  
    OP
       2018-04-18 11:32:54 +08:00
    @tempdban 加了.py 也没有用
    lukeshawn
        5
    lukeshawn  
    OP
       2018-04-18 11:39:05 +08:00
    @SingeeKing 求大神指点,一直显示:ModuleNotFoundError: No module named 'abstest'
    SingeeKing
        6
    SingeeKing  
       2018-04-18 11:54:08 +08:00 via iPad
    @lukeshawn 你执行这个语句的文件改个名
    SingeeKing
        7
    SingeeKing  
       2018-04-18 11:54:38 +08:00 via iPad
    哦不,bash 所在文件夹
    lukeshawn
        8
    lukeshawn  
    OP
       2018-04-18 11:56:10 +08:00
    @SingeeKing 什么是 bash 所在文件夹,我已经把保存的文件名加了.py ,可是还是显示 No module named 'abstest'
    tempdban
        9
    tempdban  
       2018-04-19 09:31:54 +08:00
    你这要指点的可就多了,楼上的大哥提示你了,执行 python 命令之前,先 cd 到放 abstest.py 文件的那个目录
    lukeshawn
        10
    lukeshawn  
    OP
       2018-04-20 21:55:10 +08:00
    @SingeeKing
    @tempdban
    cd 之后显示 Not a directory
    lukeshawn
        11
    lukeshawn  
    OP
       2018-04-20 21:58:44 +08:00
    @tempdban
    @SingeeKing
    按照你们的方法成功了,谢谢你们照顾我这个新人哈。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3513 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:50 · PVG 18:50 · LAX 03:50 · JFK 06:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.