为什么我的瓶子服务器以python而不是python3开头?

时间:2019-06-18 19:29:19

标签: python python-3.x bottle

这是我private async Task ButtonClickHandler(object sender, RoutedEventArgs args) { var urlList = new List<string> { "https://www.google.com/", "https://www.facebook.com/", "https://www.youtube.com/" }; await LoopUrlsAsync(urlList); } private async Task LoopUrlsAsync(List<string> urlList) { TaskCompletionSource<bool> tcsNavigation = null; TaskCompletionSource<bool> tcsDocument = null; //These event bindings can be separated out to other methods, but for simplicity I've left them here. WebBrowser.Navigated += (s, e) => { tcsNavigation.SetResult(true); }; WebBrowser.LoadCompleted += (s, e) => { //Put logic here for what you want to happen when the document is finished loading tcsDocument.SetResult(true); }; foreach (var url in urlList) { tcsNavigation = new TaskCompletionSource<bool>(); tcsDocument = new TaskCompletionSource<bool>(); WebBrowser.Navigate(url); await tcsNavigation.Task; await tcsDocument.Task; } } 文件的代码,取自Bottle的文档。

server.py

当我尝试在终端中执行此操作时,当我执行此操作时

from bottle import route, run

@route('/hello')
def hello():
    return "Hello World!"

run(host='localhost', port=8080, debug=True)

但是当我执行

python server.py

我收到以下错误:

python3 server.py

1 个答案:

答案 0 :(得分:0)

听起来您已经将Bottle安装到了Python 2环境中,但是没有将Python 3环境安装到其中。 (它们是截然不同的;在一个软件包中安装软件包不会在另一个软件包中使用。)

尝试使用pip3 install bottlepython3 -m pip install bottle,看看是否可以解决该错误。