ImportError:无法在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

现在,我尝试从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)

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

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

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

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

安德烈(Andriy Ivaneyko)

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ImportError:无法在Python中导入名称....

ImportError:无法在python-social-auth中导入名称迁移

如何解决ImportError:无法在python中导入名称splitfn

ImportError:无法在Keras中导入名称TimeDistributedDense

ImportError:无法在gpflow中导入名称“ AdamOptimizer”

ImportError:无法从“类型”中导入名称“ DictType”

我该如何解决无法ImportError:无法在python3中导入名称

如何修复ImportError:无法从Dashly(Python)中的Dash中导入名称'Event'?

ImportError:无法在新安装中导入名称“ opentype”

ImportError:无法在PyQt5中导入名称'QStringList'

如何解决ImportError:无法在Django中导入名称simplejson

出现ImportError:无法在ROS中导入名称SRV

spacy ImportError:无法在 Jupyter Notebook 中导入名称 Deque

ImportError:无法从“集合”中导入名称“容器”-heroku

无法在python中导入名称GoogleMaps

在我的conda环境中导入matplotlib时,发生ImportError:无法从“ PIL”中导入名称“ _imaging”

无法启动Docker VM:ImportError:无法从'django.utils.text'中导入名称'format_lazy'(Python错误)

Python请求ImportError:无法导入名称HeaderParsingError

Python ImportError:无法导入名称datafunc [PyML]

Python“ ImportError:无法导入名称”问题

Python,ImportError:无法导入名称AbstractLazySequence

Python 3.5“ ImportError:无法导入名称'SomeName'

Python-ImportError:无法导入名称“ HelloW”

Python ImportError:无法导入名称“ __version__”

ImportError:无法导入名称is_python_keyword

python setuptools:ImportError:无法导入名称库

ImportError:无法导入名称

ImportError:无法导入名称

无法使用python3在numpy中导入名称'multiarray'