Visual studio Can';t使用Anaconda环境运行本地服务器,以便在VS代码中绘图破折号
我正在使用Dash Plotly的应用程序()教程,它以前工作得很好。现在,如果没有以下错误消息,我似乎无法启动本地主机服务器: **更新**当我通过PyCharm运行测试服务器时,它会工作,所以不知何故,Anaconda和Jupyter似乎是个问题Visual studio Can';t使用Anaconda环境运行本地服务器,以便在VS代码中绘图破折号,visual-studio,flask,jupyter-notebook,anaconda,plotly-dash,Visual Studio,Flask,Jupyter Notebook,Anaconda,Plotly Dash,我正在使用Dash Plotly的应用程序()教程,它以前工作得很好。现在,如果没有以下错误消息,我似乎无法启动本地主机服务器: **更新**当我通过PyCharm运行测试服务器时,它会工作,所以不知何故,Anaconda和Jupyter似乎是个问题 Running on http://127.0.0.1:8050/ Debugger PIN: 749-807-877 * Serving Flask app "__main__" (lazy loading) * Environment: p
Running on http://127.0.0.1:8050/
Debugger PIN: 749-807-877
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
当我再次尝试运行服务器时,它产生以下错误:
in
19
20 if __name__ == '__main__':
---> 21 app.run_server(debug=True)
/anaconda3/lib/python3.7/site-packages/dash/dash.py in
run_server(self, port, debug, dev_tools_ui, dev_tools_props_check,
dev_tools_serve_dev_bundles, dev_tools_hot_reload,
dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval,
dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging,
**flask_run_options)
1501 self.logger.info('Debugger PIN: %s',
debugger_pin)
1502
-> 1503 self.server.run(port=port, debug=debug,
**flask_run_options)
/anaconda3/lib/python3.7/site-packages/flask/app.py in run(self,
host, port, debug, load_dotenv, **options)
941
942 try:
--> 943 run_simple(host, port, self, **options)
944 finally:
945 # reset the first request information if the
development server
/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py in
run_simple(hostname, port, application, use_reloader, use_debugger,
use_evalex, extra_files, reloader_interval, reloader_type, threaded,
processes, request_handler, static_files, passthrough_errors,
ssl_context)
793 s = socket.socket(address_family,
socket.SOCK_STREAM)
794 s.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)
--> 795 s.bind(get_sockaddr(hostname, port,
address_family))
796 if hasattr(s, 'set_inheritable'):
797 s.set_inheritable(True)
OSError: [Errno 48] Address already in use
Forums and FAQs
```import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
dcc.Input(id='my-id', value='initial value', type='text'),
html.Div(id='my-div')
])
@app.callback(
Output(component_id='my-div', component_property='children'),
[Input(component_id='my-id', component_property='value')]
)
def update_output_div(input_value):
return 'You\'ve entered "{}"'.format(input_value)
if __name__ == '__main__':
app.run_server(debug=True)```
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
Debugger PIN: 715-884-879
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
in
19
20 if __name__ == '__main__':
---> 21 app.run_server(debug=True)
/anaconda3/lib/python3.7/site-packages/dash/dash.py in run_server(self, port, debug, dev_tools_ui, dev_tools_props_check, dev_tools_serve_dev_bundles, dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging, **flask_run_options)
1501 self.logger.info('Debugger PIN: %s', debugger_pin)
1502
-> 1503 self.server.run(port=port, debug=debug, **flask_run_options)
/anaconda3/lib/python3.7/site-packages/flask/app.py in run(self, host, port, debug, load_dotenv, **options)
941
942 try:
--> 943 run_simple(host, port, self, **options)
944 finally:
945 # reset the first request information if the development server
/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py in run_simple(hostname, port, application, use_reloader, use_debugger, use_evalex, extra_files, reloader_interval, reloader_type, threaded, processes, request_handler, static_files, passthrough_errors, ssl_context)
793 s = socket.socket(address_family, socket.SOCK_STREAM)
794 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
--> 795 s.bind(get_sockaddr(hostname, port, address_family))
796 if hasattr(s, 'set_inheritable'):
797 s.set_inheritable(True)
OSError: [Errno 48] Address already in use
我检查了所有我能找到的关于这个问题的论坛,但是我似乎找不到任何解决问题的方法。
在我擦除硬盘并重新安装Anaconda、Dash和VS代码之前,运行本地服务器工作正常。
地址已在使用
表示您尝试使用的端口已被其他应用程序使用。确保您正确地关闭了以前运行过的任何Flask(Dash)服务器,或者终止了任何剩余的进程
如果您需要使用其他端口,您可以将
app.run_server(debug=True)
更改为app.run_server(debug=True,port=1337)
感谢您的响应,但即使在端口更改后,无论端口是什么,它都会返回完全相同的错误。为什么?这可能是问题所在吗?请参阅以下内容:环境:生产警告:不要在生产环境中使用开发服务器。我怎么解决这个问题?你找到解决办法了吗@彼得,我也有同样的问题