且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

脚本在PyCharm中运行,但不是从命令行运行

更新时间:2023-02-22 11:02:36

有一些可能的原因可能导致这种情况:

There are a few possible things that can be causing this:

  1. 同一个python解释器?用import sys; print(sys.executable)
  2. 检查
  3. 它是同一工作目录吗?用import os; print(os.getcwd())
  4. 检查
  5. sys.path中的差异(python依次搜索导入位置的列表)可能是环境变量引起的.用import sys; print(sys.path)检查.
  1. The same python interpreter? Check with import sys; print(sys.executable)
  2. Is it the same working directory? Check with import os; print(os.getcwd())
  3. Discrepancies in sys.path, which is the list python searches sequentially for import locations, can possibly caused by environment variables. Check with import sys; print(sys.path).