Script running in PyCharm but not from the command line

后端 未结 4 1194
孤城傲影
孤城傲影 2020-12-01 14:33

When I try to run my program from the PyCharm IDE everything works fine but if I type in Fedora:

python myScript.py

in a shell prompt I get

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 15:05

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

    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).

提交回复
热议问题