导入包不起作用 - 可能是版本冲突

时间:2016-02-20 17:52:09

标签: python packages anaconda

经过很长一段时间,事情进展顺利(我的意思是我可以点击安装包,然后在带有import语句的jupyter笔记本中使用它们),我最近遇到了多个问题。

我认为这是在我从Continuum Analytics升级我的anaconda安装时发生的(虽然不确定)

我收到基本导入的错误报告,如pandas或matplotlib,如

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-adcb0ce40833> in <module>()
      1 # Plot softmax curves
----> 2 import matplotlib.pyplot as plt

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/site-    packages/matplotlib/__init__.py in <module>()
   1129 
   1130 # this is the instance used by the matplotlib classes
-> 1131 rcParams = rc_params()
   1132 
   1133 if rcParams['examples.directory']:

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/site-packages/matplotlib/__init__.py in rc_params(fail_on_error)
    973         return ret
    974 
--> 975     return rc_params_from_file(fname, fail_on_error)
    976 
    977 

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/site-   packages/matplotlib/__init__.py in rc_params_from_file(fname, fail_on_error,     use_default_template)
   1098         parameters specified in the file. (Useful for updating dicts.)
   1099     """
-> 1100     config_from_file = _rc_params_in_file(fname, fail_on_error)
   1101 
   1102     if not use_default_template:

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/site-packages/matplotlib/__init__.py in _rc_params_in_file(fname, fail_on_error)
   1016     cnt = 0
   1017     rc_temp = {}
-> 1018     with _open_file_or_url(fname) as fd:
   1019         try:
   1020             for line in fd:

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/contextlib.pyc in  __enter__(self)
     15     def __enter__(self):
     16         try:
---> 17             return self.gen.next()
     18         except StopIteration:
     19             raise RuntimeError("generator didn't yield")

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/site-    packages/matplotlib/__init__.py in _open_file_or_url(fname)
    998     else:
    999         fname = os.path.expanduser(fname)
-> 1000         encoding = locale.getdefaultlocale()[1]
   1001         if encoding is None:
   1002             encoding = "utf-8"

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/locale.pyc in     getdefaultlocale(envvars)
    541     else:
    542         localename = 'C'
--> 543     return _parse_localename(localename)
    544 
    545 

/Users/peterhirt/anaconda/envs/tensorflow/lib/python2.7/locale.pyc in _parse_localename(localename)
    473     elif code == 'C':
    474         return None, None
--> 475     raise ValueError, 'unknown locale: %s' % localename
    476 
    477 def _build_localename(localetuple):

ValueError: unknown locale: UTF-8

所以,我尝试使用一个特定的环境,我首先安装了我想要使用的python版本,然后添加了tensorflow之类的东西(非常好)

我是通过

来做到的
conda create tensorflow python=2.7

这为我创建了一个名为tensorflow的环境并安装了python版本2.7

然后我通过

激活envrionment
source activate tensorflow

然后,我添加了matplotlib

pip install matplotlib

我又得到了这个错误

我迷路了。我认为它与不兼容的软件包有关,但我不能解决它并解决它。

有人可以帮助我吗

提前致谢

彼得

0 个答案:

没有答案