[英]My python script runs through my IDE (PyCharm) but it won't run using the Python shell
I have a short python script that uses the logging module and the configparser module. 我有一个简短的python脚本,它使用日志记录模块和configparser模块。 I use PyCharm 2.7.1 and Python 3.3 under Win7.
我在Win7下使用PyCharm 2.7.1和Python 3.3。
When I run my script using PyCharm - it works. 当我使用PyCharm运行脚本时,它可以工作。 This is the output from the PyCharm console:
这是PyCharm控制台的输出:
C:\Python33\python.exe C:/some/path/script.py
Process finished with exit code 0
I run the same command in the cmd and this is what I get: 我在cmd中运行相同的命令,这就是我得到的:
C:\>C:\Python33\python.exe C:/some/path/script.py
Traceback (most recent call last):
File "C:/some/path/script.py", line 10
1, in <module>
initLogger()
File "C:/some/path/script.py", line 97, in initLogger
logging.config.fileConfig('RecorderMoverLog.config.ini')
File "C:\Python33\lib\logging\config.py", line 70, in fileConfig
formatters = _create_formatters(cp)
File "C:\Python33\lib\logging\config.py", line 103, in _create_formatters
flist = cp["formatters"]["keys"]
File "C:\Python33\lib\configparser.py", line 942, in __getitem__
raise KeyError(key)
KeyError: 'formatters'
Why does it run in PyCharm and won't run under python shell? 为什么它在PyCharm中运行而不能在python shell下运行?
Thanks 谢谢
It is most likely because of your PYTHON_PATH
. 这很可能是由于您的
PYTHON_PATH
。 List sys.path
in your Python IDE and in your Python in shell. 在Python IDE和Shell中的Python中列出
sys.path
。 Look for the difference in the Python libraries. 在Python库中寻找差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.