当用PY Launcher调用模块时,为什么我必须用下划线替换所有连字符?

发布于 2025-01-23 21:29:42 字数 1437 浏览 1 评论 0原文

我正在使用 python parinterer Windows简化版本管理并避免修改系统路径。

我已经成功安装了一些软件包:

> py -m pip list
Package            Version
------------------ ---------
Brotli             1.0.9
certifi            2021.10.8
charset-normalizer 2.0.12
gallery-dl         1.21.1
idna               3.3
mutagen            1.45.1
pip                22.0.4
pycryptodomex      3.14.1
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
websockets         10.3
yt-dlp             2022.4.8

它们均在Program Files/Python310/Scripts中列出:

“在此处输入图像说明”

但是当我尝试称呼他们时,我会收到以下错误:

> py -m gallery-dl
C:\Program Files\Python310\python.exe: No module named gallery-dl

除非我用下划线替换连字符:

> py -m gallery_dl --help
usage: __main__.py [OPTION]... URL...

General Options:
...

这与我不使用发射器并在路径中使用Python的情况大不相同,并且可以在PowerShell内部拨打Gallery -dl,而无需:

  • 准备py -m - 可以用下划线
  • 替换连字符 - 这不太好,因为它感觉就像我在调用
  • 具有__ main __. py: bit的原始功能 -对了。

这是预期和适当的行为,还是[我在做 /做我做的]错误?

I'm using the Python launcher on Windows to simplify version management and avoid modifying system path.

I've successfully installed a few packages:

> py -m pip list
Package            Version
------------------ ---------
Brotli             1.0.9
certifi            2021.10.8
charset-normalizer 2.0.12
gallery-dl         1.21.1
idna               3.3
mutagen            1.45.1
pip                22.0.4
pycryptodomex      3.14.1
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
websockets         10.3
yt-dlp             2022.4.8

They're all listed under Program Files/Python310/Scripts:

enter image description here

but when I try to call them I get the following error:

> py -m gallery-dl
C:\Program Files\Python310\python.exe: No module named gallery-dl

unless I replace hyphens with underscores:

> py -m gallery_dl --help
usage: __main__.py [OPTION]... URL...

General Options:
...

This is quite different from when I wasn't using the launcher and had python in PATH and could just call gallery-dl inside Powershell without:

  • prepending py -m - which is fine
  • replacing hyphens with underscores - which is less fine because it sort of feels like I'm calling a raw function
  • having the __main__.py: bit - which doesn't feel right either.

Is this the expected and proper behavior, or [am I doing / did I do] something wrong?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文