Home  >  Q&A  >  body text

python splinter一运行就No module named browser

最近要使用splinter进行一些工具开发,在使splinter的过程中遇到一些奇葩问题。 这些相关依赖模块selenium lxml cython我都已经安装 单独使用selenium是没用问题的。但是在使用splinter的时候就有问题 百度谷歌一直找不到错误! 我的错误信息如下: ​from splinter.browser import Browser ImportError: No module named browser ​怎么回事啊,我splinter也正确安装import splinter ,IDE也没用报错,但是一运行就报错,怎么会没有browser模块呢?

PHP中文网PHP中文网2742 days ago854

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:44:44

    This is a common mistake made by novices. The problem lies in not understanding the python module search path.

    Import module ​from splinter.browser import Browser and first search for files named splinter.py in the current directory. Then search for the environment variable PYTHONPATH

    The search directory contains and first searches the directory where the current script is running, so the name of the script must not have the same name as the module name, otherwise the script will be loaded as a module.

    Refer to official documentation

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:44:44

    I also encountered such a problem, the solution is not to start the file name with splinter.py, it can be aa.py, bb.py

    reply
    0
  • Cancelreply