在python3中导入时出现unicode错误

时间:2016-11-20 05:49:16

标签: python-3.x pandas unicode syntax-error python-import

我尝试导入pandas_datareader.data以使用DataReader,但它会像这样一直返回unicode错误:

In[38]: import pandas_datareader.data
Traceback (most recent call last):
  File "C:\Users\mone\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3066, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-38-8725a3b77af5>", line 1, in <module>
import pandas_datareader.data
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
  File "C:\Users\mone\Anaconda3\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
  File "C:\Users\mone\Anaconda3\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
  File "C:\Users\mone\Anaconda3\lib\site-packages\pandas_datareader\base.py", line 3, in <module>
import numpy as np
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
  File "C:\Users\mone\Anaconda3\lib\site-packages\numpy\__init__.py", line 126, in <module>
from numpy.__config__ import show as show_config
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
  File "C:\Users\mone\Anaconda3\lib\site-packages\numpy\__config__.py", line 5
lapack_opt_info={'define_macros': [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)], 'libraries': ['mkl_core_dll', 'mkl_intel_c_dll', 'mkl_intel_thread_dll'], 'library_dirs': ['C:\Users\mone\Anaconda3\\Library\\lib'], 'include_dirs': ['C:\Users\mone\Anaconda3\\Library\\include']}
                                                                                                                                                                           ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

我只是输入

In[38]: import pandas_datareader.data

在Pycharm的Python控制台中。

似乎&#39; \ U&#39; C:\用户......&#39;的一部分这是一个问题,但我无法用它做任何事情,例如加倍反斜线等等。

这个错误不仅发生在这种情况下,也发生在许多其他情况上。

有趣的是,只需导入&#39; pandas_datareader&#39;的工作原理。

任何解决方案?

0 个答案:

没有答案