gpt4 book ai didi

python - 查找错误 : unknown encoding: cp0

转载 作者:太空狗 更新时间:2023-10-30 02:47:08 34 4
gpt4 key购买 nike

我在 window 7、python 2.7.2、pandas 0.11.0、django 1.4、wsgi 和 apache 2.2 上。我有一个 pandas 脚本,如果我直接用 python 运行它就可以正常工作,也可以在 ipython 中使用 %run 运行。但是,当我在我的 View 中运行 pandas 时,我得到“LookupError:未知编码:cp0”。只有在 View 中的 pandas 中使用 ols 时才会发生这种情况。我也有点困惑为什么 py3compat.py 在我使用 python 2.7 时进入画面。另外,我看过一些关于在 str() 中包装打印变量的帖子,但我不确定这在此处如何应用。整个追溯是:

Traceback (most recent call last):
model = pd.ols(y=df_loan['LogSpread'], x=df_loan['Dummy Rating'])
File "C:\\Python27\\lib\\site-packages\\pandas\\stats\\interface.py", line 135, in ols
return klass(**kwargs)
File "C:\\Python27\\lib\\site-packages\\pandas\\stats\\ols.py", line 43, in __init__
import statsmodels.api as sm
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\api.py", line 3, in <module>
import regression
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\regression\\__init__.py", line 1, in <module>
from linear_model import yule_walker
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\regression\\linear_model.py", line 41, in <module>
import statsmodels.base.model as base
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\base\\model.py", line 10, in <module>
from statsmodels.formula import handle_formula_data
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\formula\\__init__.py", line 4, in <module>
from formulatools import handle_formula_data
File "C:\\Python27\\lib\\site-packages\\statsmodels-0.5.0-py2.7-win32.egg\\statsmodels\\formula\\formulatools.py", line 2, in <module>
from patsy import dmatrices
File "build\\bdist.win32\\egg\\patsy\\__init__.py", line 70, in <module>
_reexport("patsy." + child)
File "build\\bdist.win32\\egg\\patsy\\__init__.py", line 61, in _reexport
__import__(modname)
File "build\\bdist.win32\\egg\\patsy\\highlevel.py", line 18, in <module>
File "build\\bdist.win32\\egg\\patsy\\design_info.py", line 17, in <module>
File "build\\bdist.win32\\egg\\patsy\\util.py", line 385, in <module>
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\__init__.py", line 46, in <module>
from .frontend.terminal.embed import embed
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\frontend\\terminal\\embed.py", line 39, in <module>
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\frontend\\terminal\\interactiveshell.py", line 33, in <module>
from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\core\\interactiveshell.py", line 61, in <module>
from IPython.core.prompts import PromptManager
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\core\\prompts.py", line 138, in <module>
HOME = py3compat.str_to_unicode(os.environ.get("HOME","//////:::::ZZZZZ,,,~~~"))
File "C:\\Python27\\lib\\site-packages\\ipython-0.13.1-py2.7.egg\\IPython\\utils\\py3compat.py", line 18, in decode
return s.decode(encoding, "replace")
LookupError: unknown encoding: cp0

非常感谢!

最佳答案

关闭 Spyder。

打开 Anaconda Prompt 并输入:set PYTHONIOENCODING=UTF-8。或者,创建一个名称为 PYTHONIOENCODING 且值为 UTF-8 的环境变量。

键入 spyder 重新开始。

关于python - 查找错误 : unknown encoding: cp0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17096631/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com