【问题标题】:How to run python without module from command line如何从命令行运行没有模块的python
【发布时间】:2018-09-19 04:55:14
【问题描述】:

我有两个 python 文件my_python.py

# my_pyhton.py
from myPython import my_utils
...
logger = my_utils.get_logger
..

my_utils.py都在文件夹myPython中:

# my_utils.py
def get_logger():
....

我可以在 eclipse PyDev 中毫无问题地运行它们,但是当我在命令行中运行它们时,出现如下错误:

Traceback (most recent call last):
  File "my_pyhton.py", line 19, in <module>
    from myPyhton import my_utils
ModuleNotFoundError: No module named 'myPython'

我该怎么做才能像在 Eclipse 中一样运行它们?

【问题讨论】:

  • 尝试在my_python.py中导入import my_utils
  • Unresolved import: my_utils in my_python.py
  • 导入时是否使用冒号?
  • 当然,不!只是import my_utils
  • 你看了吗this

标签: python-3.x eclipse command-line python-module


【解决方案1】:

这对我来说没问题

from my_utils import get_logger, get_driver, get_home_path

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2018-02-26
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    • 1970-01-01
    • 2021-07-18
    相关资源
    最近更新 更多