解决window7 x64位Anaconda启动报错:AttributeError: '_NamespacePath' object has no attribute 'sort'

最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下载全,还有好几个其他的统计包也是如此,整晕了算。

看网上有些python大牛推荐Anaconda,可以解决包的问题,于是卸载本地的python,从官网上下了个Anconda玩玩,结果遇到新问题。

问题如下:

An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues

Current conda install:

               platform : win-64
          conda version : 4.3.21
       conda is private : False
      conda-env version : 4.3.21
    conda-build version : not installed
         python version : 3.6.1.final.0
       requests version : 2.14.2
       root environment : d:\ProgramData\Anaconda3  (writable)
    default environment : d:\ProgramData\Anaconda3
       envs directories : d:\ProgramData\Anaconda3\envs
                          C:\Users\user\AppData\Local\conda\conda\envs
                          C:\Users\user\.conda\envs
          package cache : d:\ProgramData\Anaconda3\pkgs
                          C:\Users\user\AppData\Local\conda\conda\pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
            config file : None
             netrc file : None
           offline mode : False
             user-agent : conda/4.3.21 requests/2.14.2 CPython/3.6.1 Windows/7 Windows/6.1.7601
          administrator : True

`$ d:\ProgramData\Anaconda3\Scripts\conda-script.py ..checkenv cmd.exe d:\ProgramData\Anaconda3`

    Traceback (most recent call last):
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 167, in main
        import conda.cli.activate as activate
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\cli\activate.py", line 12, in <module>
        from ..utils import shells
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\utils.py", line 13, in <module>
        from .gateways.disk.read import compute_md5sum
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\disk\read.py", line 22, in <module>
        from ...models.channel import Channel
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\models\channel.py", line 9, in <module>
        from ..base.context import context
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\base\context.py", line 18, in <module>
        from .._vendor.auxlib.path import expand
      File "d:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\path.py", line 8, in <module>
        import pkg_resources
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load
      File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2985, in <module>
        @_call_aside
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2971, in _call_aside
        f(*args, **kwargs)
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 3013, in _initialize_master_working_set
        dist.activate(replace=False)
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2544, in activate
        declare_namespace(pkg)
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2118, in declare_namespace
        _handle_ns(packageName, path_item)
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2058, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2087, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: ‘_NamespacePath‘ object has no attribute ‘sort‘

经过一番查找,解决方法如下:

问题解决原链接(英文):https://github.com/conda/conda/pull/5496

找到你的Anaconda安装目录中的path.py,详细路径为:D:\ProgramData\Anaconda3\Lib\site-packages\conda\_vendor\auxlib\path.py

把文件path.py中,“except ImportError: ”修改为“except Exception:“

在运行Anaconda Prompt,输入conda,效果图如下:

希望对踩坑的朋友有帮助。

解决window7 x64位Anaconda启动报错:AttributeError: '_NamespacePath' object has no attribute 'sort'

时间: 2025-01-01 04:20:51

解决window7 x64位Anaconda启动报错:AttributeError: '_NamespacePath' object has no attribute 'sort'的相关文章

zc.buildout构建项目时报错‘AttributeError: &#39;_NamespacePath&#39; object has no attribute &#39;sort&#39;’

在使用zc.buildout构建项目时如果碰到'AttributeError: '_NamespacePath' object has no attribute 'sort''报错: An internal error occurred due to a bug in either zc.buildout or in a recipe being used: Traceback (most recent call last): File "c:\python36\lib\site-package

python jieba 结巴分词报错 AttributeError: &#39;module&#39; object has no attribute &#39;cut&#39;

首先这个AttributeError: ‘module’ object has no attribute ‘cut’ 报错的原因是因为有jieba.py这个文件存在,或者jieba这样命名的文件存在,很多新人使用结巴 来分词的时候命名直接为jieba.py,但是其实官方给的教程代码里有import jieba,这样就会引用到你自己这个教程文件jieba.py,而没有引用官方的库,这样自然cut这个方法就没有,所以报错.解决方法:1.不要使用jieba.py来命名你的测试文件.2.你一开始就是用j

python-pip升级报错- AttributeError: &#39;NoneType&#39; object has no attribute &#39;bytes&#39;

正常的pip升级命令: python -m pip install --upgrade pip 在pytharm里面创建了一个Python项目,pytharm会自动搭建一个新的Python环境,在当前的目录下使用 python -m pip install --upgrade pip 会报错 AttributeError: 'NoneType' object has no attribute 'bytes' 可以使用如下方式 easy_install -U pip python-pip升级报错-

Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attribute 'xxx'".这其实是.pyc文件存在问题. 问题定位: 查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件 问题解决方法: 1. 命名py脚本时,不要与python预留字,模块名等相同 2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件

facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: &#39;dict&#39; object has no attribute &#39;iteritems&#39;

报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute 'iteritems' 解决方案:由于我的python时3.5的,Python3.5中:iteritems变为items,找到train_softmax程序修改如下: facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' obj

python中引入包的时候报错AttributeError: module &#39;sys&#39; has no attribute &#39;setdefaultencoding&#39;解决方法?

python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdefaultencoding('utf-8') AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法: 1.python2中解决方法:reload(sys)sys.setdefaultencoding('utf-8'

Python - celery 相关报错 - AttributeError: type object &#39;_multiprocessing.win32&#39; has no attribute &#39;WAIT_OBJECT_0&#39;

报错场景 执行   celery worker -A tasks -l INFO  打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip install celery==3.1.25 降级后再次执行会触发 另一报错 此报错原因是 redis 的版本过高导致 对 redis 进行降级即可  pip install redis==2.10.6 Python - celery 相关报错 - AttributeError: type object '_m

Python报错“AttributeError: module &#39;sys&#39; has no attribute &#39;setdefaultencoding&#39;问题”

Python3中写法: import imp import sys imp.reload(sys) Python2中写法: import sys reload(sys) sys.setdefaultencoding("utf-8") Python报错"AttributeError: module 'sys' has no attribute 'setdefaultencoding'问题" 原文地址:https://www.cnblogs.com/yznmj-112/

SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required

Spring Boot发布war包流程: 1.修改web model的pom.xml <packaging>war</packaging> SpringBoot默认发布的都是jar,因此要修改默认的打包方式jar为war 2.修改web model的依赖(dependency) <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boo