ImportError:无法在python瓶中导入名称路由

Sun*_*jan 3 python

我正在尝试开始学习python bottle框架,我已经安装了python 2.7.11,并且还安装了pip,我已经使用

pip install bottle
Collecting bottle
  Using cached bottle-0.12.9.tar.gz
Installing collected packages: bottle
  Running setup.py install for bottle ... done
Successfully installed bottle-0.12.9
Run Code Online (Sandbox Code Playgroud)

现在,我尝试从Bottle网站运行示例代码

from bottle import route, run, template
@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,它将引发以下错误

Traceback (most recent call last):
  File "C:/Users/SID/Desktop/bottle.py", line 1, in <module>
    from bottle import route, run, template
  File "C:/Users/SID/Desktop\bottle.py", line 1, in <module>
    from bottle import route, run, template
ImportError: cannot import name route
Run Code Online (Sandbox Code Playgroud)

我不知道出了什么问题可以有人指导我,这是代码的错误吗?还是瓶装?

注意:我在运行程序时尝试过python 3.4.3仍然仍然面临相同的错误,并且我在虚拟框中使用Windows 8.1

And*_*yko 5

bottle.py的项目文件夹中有文件。发生问题是因为python模块C:/Users/SID/Desktop/bottle.py遮蔽bottle.py了pip安装的模块。重命名影子真实bottle.py模块文件以解决导入问题。

应重命名的文件位置为C:/Users/SID/Desktop/bottle.py