最近论文需要用到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-
conda version : 4.3.
conda is private : False
conda-env version : 4.3.
conda-build version : not installed
python version : 3.6..final.
requests version : 2.14.
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. requests/2.14. CPython/3.6. Windows/ Windows/6.1.
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 , in main
import conda.cli.activate as activate
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\cli\activate.py", line , in <module>
from ..utils import shells
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\utils.py", line , in <module>
from .gateways.disk.read import compute_md5sum
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\disk\read.py", line , in <module>
from ...models.channel import Channel
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\models\channel.py", line , in <module>
from ..base.context import context
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\base\context.py", line , in <module>
from .._vendor.auxlib.path import expand
File "d:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\path.py", line , in <module>
import pkg_resources
File "<frozen importlib._bootstrap>", line , in _find_and_load
File "<frozen importlib._bootstrap>", line , in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line , in _load_unlocked
File "<frozen importlib._bootstrap>", line , in _load_backward_compatible
File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line , in <module>
@_call_aside
File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line , 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 , 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 , in activate
declare_namespace(pkg)
File "d:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line , 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 , 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 , 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,效果图如下:

这里问题还没有彻底解决,在PyCharm这种编译器指向Python的时候,还是会出问题,问题如下:

这时候需要更新Pip,打开Anaconda Prompt,输入命令conda update conda pip,联网更新pip

在打开pycharm,右下角会更新一些python信息

然后还没有完,更新完了跑,还是出问题,问题如下:

最后一气之下,找到D:\ProgramData\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg,然后删除(不放心的话,剪切到别的地方)

然后运行,好了。。。。

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

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

  1. zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’

    在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...

  2. 解决Win7(x64)Anaconda3报错:AttributeError: '_NamespacePath' object has no attribute 'sort'

    最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下 ...

  3. py+selenium 明明定位不到元素,但却不报错或是报错AttributeError: 'list' object has no attribute 'click'【已解决】

    问题:定位不到元素,但却不报错或者出现报错AttributeError: 'list' object has no attribute 'click' 如图  或者  解决方法:   将”driver ...

  4. dnspython模块报错 AttributeError: 'CNAME' object has no attribute 'address'

    有时候用到这个模块的时候会报错 AttributeError: 'CNAME' object has no attribute 'address' 如下所示 [root@ansible ch01]# ...

  5. 关于flask登录视图报错AttributeError: '_AppCtxGlobals' object has no attribute 'user'

    在一个小程序中写了一个登录视图函数,代码如下: @app.route('/login',methods = ['GET','POST']) @oid.loginhandler def login(): ...

  6. Django2.2报错 AttributeError: 'str' object has no attribute 'decode'

    准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: AttributeError: 'str' object has ...

  7. 机器学习实战:KNN代码报错“AttributeError: 'dict' object has no attribute 'iteritems'”

    报错代码: sortedClassCount = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse=True) 解决 ...

  8. 运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"

    最近学习pytest被此问题困扰,敲脑壳,实在是不该.百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢. 报错信息如下: 网上解决方法是这样的 ...

  9. [已解决]报错:报错AttributeError: 'int' object has no attribute 'upper'

    原因:openpyxl版本低,需升级 pip install --upgrade openpyxl

随机推荐

  1. Python LED

    led.py from gpiozero import LED from time import sleep led = LED(17) while True: print "start c ...

  2. (入门篇 NettyNIO开发指南)第五章-分隔符和定长解码器使用

    TCP    以流的方式进行数据传输上层的应用协议为了对消息进行区分,往往采用如下4种方式. (1)消息长度固定,累计读取到长度总和为定长LEN 的报文后,就认为读取到了一个完整的消息,将计数器置位, ...

  3. Python爬虫02——贴吧图片爬虫V2.0

    Python小爬虫——贴吧图片爬虫V2.0 贴吧图片爬虫进阶:在上次的第一个小爬虫过后,用了几次发现每爬一个帖子,都要自己手动输入帖子链接,WTF这程序简直反人类!不行了不行了得改进改进. 思路: 贴 ...

  4. Factoextra R Package: Easy Multivariate Data Analyses and Elegant Visualization

    factoextra is an R package making easy to extract and visualize the output of exploratory multivaria ...

  5. R语言 模糊c均值(FCM)算法程序(转)

    FCM <- function(x, K, mybeta = 2, nstart = 1, iter_max = 100, eps = 1e-06) { ## FCM ## INPUTS ## ...

  6. 利用wget检测网页是否正常访问

    #!/bin/bash function CheckUrl() { timeout=5 fails=0 success=0 while true do wget --timeout=5 --tries ...

  7. PHP实现Collection数据集类及其原理

    本文目录 : Collection源码 讲解与例子 ArrayAccess的使用 JsonSerializable的使用 Countable的使用 IteratorAggregate.ArrayIte ...

  8. Idea中执行TestNg报错

    今天在Idea中使用TestNg过程中报错: java.lang.AbstractMethodError: org.testng.remote.RemoteTestNG$DelegatingTestR ...

  9. 【easyui】Tab的tools按钮刷新当前tab

    点击刷新按钮,刷新当前Tab选项卡 /** * Name 选项卡初始化 */ $('#home-tabs').tabs({ tools: [{ iconCls: 'icon-reload', bord ...

  10. ajax 动态添加商品列表

    <!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...