更改 pydev 中的端口

发布于 2024-12-26 13:25:15 字数 539 浏览 2 评论 0原文

大家好,我正在尝试学习 django 框架,并且正在使用 PyDev(Eclipse Python 开发框架/插件)。当我尝试运行我的应用程序时,出现错误:

Error: [Errno 10013]

我知道这是由于端口造成的。我使用端口 8000,我想将其更改为 8080。有谁知道我到底应该做什么来更改端口?

 pydev debugger: starting
 Validating models...

 0 errors found
 Django version 1.3.1, using settings 'muapp.settings'
 Development server is running at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 Error: [Errno 10013]

指出 PyDev 与 Eclipse 一样,在按下 Run 按钮时运行配置的命令可能会很有用。默认命令和/或其选项如何更改?

Hi everyone i'm trying to learn the django framework and I'm using PyDev (Eclipse Python Development Framework/Plugin). When I try to run my application I get an error:

Error: [Errno 10013]

I know that this is because of the port. I use the port 8000 and i want to change it to 8080. Does anyone knows what exactly should i do to change the port?

 pydev debugger: starting
 Validating models...

 0 errors found
 Django version 1.3.1, using settings 'muapp.settings'
 Development server is running at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 Error: [Errno 10013]

It might be useful to point out that PyDev, like Eclipse, runs the configured command when the Run button is pressed. How is the default command and/or its options changed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

残龙傲雪 2025-01-02 13:25:15

观看此视频教程。跳过大约 14 分钟。然后在参数中使用 runserver 8080 而不是 runserver。

Have a look at this video tutorial. Skip about 14 minutes in. Then use runserver 8080 instead of runserver in the arguments.

最单纯的乌龟 2025-01-02 13:25:15

请查看 PyDev 文档,了解如何更改运行 配置。

作为 Django 运行/调试

作为 Django 运行/调试,因为 Django 可用(请注意,它们设置了
--默认情况下不加载)。

这将创建默认的运行配置,因此您可以对其进行编辑
稍后通过运行>运行配置(或调试>调试
配置)如果您想更改参数。

注意:要了解如何重新运行上次启动,请参阅:重新运行上次启动
关于 PyDev 启动的主题

注2:如果不传递--noreload,则只有父进程会
会被 Eclipse 杀死,而其他人只会在他们
重新加载(即:在代码更改时)。

无论是“Eclipse”还是“PyDev”,右键单击项目并选择“Run As”--> “运行配置...”

运行配置

另外,根据 django 文档,

运行服务器[地址]¶

在本地计算机上启动轻量级开发 Web 服务器。经过
默认情况下,服务器在 IP 地址 127.0.0.1 的端口 8000 上运行。你
可以显式传入 IP 地址和端口号。

因此,在项目的运行配置中的参数选项卡上,只需添加:

runserver 0.0.0.0:8080

这应该让服务器侦听所有接口/IP。或者,您可以使其更具体地针对您的面向公众的 IP:

runserver 123.456.789.123:45678

请注意,在这种情况下,我的 IP 将为“123.456.789.123”,端口将为“45678”。


以下答案也可能有用:

Please take a look at the PyDev Documentation on how to change the Run configuration.

Run/Debug as Django

Run as Django/Debug as Django are available (note that they set the
--noreload by default).

This will create a default Run configuration, so, you may edit it
later through run > run configurations (or debug > debug
configurations) if you want to change a parameter.

Note: to know how to rerun the last launch see: the Rerun Last Launch
topic on PyDev Launching

Note 2: if the --noreload is not passed, only the parent process will
be killed from Eclipse and the others will only be killed when they'd
be reloaded (i.e.: on a code-change).

Whether it's "Eclipse" or "PyDev", right-click on the Project and select "Run As" --> "Run Configurations..."

Run Configuration

Additionally, according to the django Documentation,

runserver [addrport]¶

Starts a lightweight development Web server on the local machine. By
default, the server runs on port 8000 on the IP address 127.0.0.1. You
can pass in an IP address and port number explicitly.

Therefore, in your Project's Run Configuration, on the Arguments tab, simply add:

runserver 0.0.0.0:8080

This should have the server listen on all interfaces/IPs. Alternatively, you can make it more specific to your public-facing IP instead:

runserver 123.456.789.123:45678

Please, note that in this case, my IP would be "123.456.789.123" and the port would be "45678".


The following Answers might also be of use:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文