久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ValueError:使用 conda 命令后無法解析 CPython sys.ver

ValueError: failed to parse CPython sys.version after using conda command(ValueError:使用 conda 命令后無法解析 CPython sys.version)
本文介紹了ValueError:使用 conda 命令后無法解析 CPython sys.version的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我遇到了一個(gè)我無法解決的錯(cuò)誤,盡管其他人報(bào)告了同樣的錯(cuò)誤.

I'm running into an error that I can't solve despite others having reported the same error.

我正在遠(yuǎn)程連接到 Linux 機(jī)器.我已經(jīng)安裝了最新版本的 anaconda:

I am connecting remotely to a Linux machine. I have installed the latest version of anaconda:

$ bash Anaconda2-2.4.0-Linux-x86_64.sh

// A lot of python libraries get installed

installing: _cache-0.0-py27_x0 ...
Python 2.7.10 :: Continuum Analytics, Inc.
creating default environment...
installation finished. 

我更新了對(duì)應(yīng)的路徑,好像可以了:

I updated the corresponding paths and it seems like it works:

$ python
Python 2.7.10 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 18:04:42) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

太好了,所以現(xiàn)在我想使用 Anaconda 預(yù)裝的 conda.看起來 Anaconda 給了我 3.18.3:

Great, so now I want to use conda, which is pre-installed with Anaconda. It looks like Anaconda gave me 3.18.3:

$ conda --version
conda 3.18.3

按照試駕說明,我更新了conda:

Following the test drive instructions, I update conda:

$ conda update conda
Fetching package metadata: An unexpected error has occurred, please consider sending the
following traceback to the conda GitHub issue tracker at:

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

Include the output of the command 'conda info' in your report.


Traceback (most recent call last):
  File "/code/anaconda2-4-0/bin/conda", line 5, in <module>
    sys.exit(main())
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/cli/main.py", line 195, in main
    args_func(args, p)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/cli/main.py", line 202, in args_func
    args.func(args, p)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/cli/main_update.py", line 48, in execute
    install.install(args, parser, 'update')
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/cli/install.py", line 239, in install
    offline=args.offline)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/cli/common.py", line 598, in get_index_trap
    return get_index(*args, **kwargs)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/api.py", line 42, in get_index
    unknown=unknown)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/utils.py", line 119, in __call__
    value = self.func(*args, **kw)
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/fetch.py", line 237, in fetch_index
    session = CondaSession()
  File "/code/anaconda2-4-0/lib/python2.7/site-packages/conda/connection.py", line 61, in __init__
    super(CondaSession, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 272, in __init__
    self.headers = default_headers()
  File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 555, in default_headers
    'User-Agent': default_user_agent(),
  File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 524, in default_user_agent
    _implementation = platform.python_implementation()
  File "/usr/lib/python2.7/platform.py", line 1521, in python_implementation
    return _sys_version()[0]
  File "/usr/lib/python2.7/platform.py", line 1486, in _sys_version
    repr(sys_version))
ValueError: failed to parse CPython sys.version: '2.7.10 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 18:04:42) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'

很遺憾,我不知道如何避免這個(gè)錯(cuò)誤.

Unfortunately, I can't figure out how to avoid this error.

我發(fā)現(xiàn)了一些其他 StackOverflow 帖子.這個(gè)建議從頭開始重新安裝python和pycharm(但我剛剛安裝了Anaconda,我不使用pycharm).另一個(gè)建議重新安裝機(jī)蓋,但我'我不在這里使用它.最后,第三個(gè)建議這實(shí)際上是一個(gè)錯(cuò)誤,并提出了修復(fù)建議.不幸的是,重命名 sys.version 無法解決錯(cuò)誤.這甚至不是我的電腦,所以我不想深入研究代碼并冒險(xiǎn)搞砸.

I found a few other StackOverflow posts. This one suggests reinstalling python and pycharm from scratch (but I just installed Anaconda and I don't use pycharm). Another suggests reinstalling canopy, but I'm not using that here. Finally, a third suggests that it's actually a bug, and proposes a fix. Unfortunately, re-naming sys.version fails to resolve the error. This isn't even my computer so I don't want to get deep into the code and risk messing something up.

我會(huì)很感激一些想法或建議.

I would appreciate some thoughts or advice.

推薦答案

第三種解決方案是正確的.這確實(shí)是一個(gè)錯(cuò)誤,因?yàn)樾薷暮蟮?sys.version 字符串破壞了許多依賴于具有特定格式的字符串的 platform 模塊函數(shù).

Third solution is correct. This is indeed a bug, since modified sys.version string breaks a number of platform module functions that rely on that string having certain format.

但是,如果您無法正確修復(fù)它,您可以嘗試一個(gè) hacky 解決方法.模塊 platform 實(shí)際上有一個(gè)用于解析 sys.version 字符串的緩存:所以你要做的是:

However, if you cannot fix it properly, you can attempt a hacky workaround. Module platform actually has a cache for parsing sys.version string: so what you have to do is:

  1. 備份 Anaconda 修改的 sys.version.
  2. 將其替換為合法版本字符串.
  3. 調(diào)用任何能夠解析 sys.version 字符串的 platform 模塊函數(shù).
  4. 為 Anaconda 修改的 sys.version 復(fù)制它的緩存.
  5. 從備份中恢復(fù) sys.version.

破解自己:

try:
    import sys # Just in case
    start = sys.version.index('|') # Do we have a modified sys.version?
    end = sys.version.index('|', start + 1)
    version_bak = sys.version # Backup modified sys.version
    sys.version = sys.version.replace(sys.version[start:end+1], '') # Make it legible for platform module
    import platform
    platform.python_implementation() # Ignore result, we just need cache populated
    platform._sys_version_cache[version_bak] = platform._sys_version_cache[sys.version] # Duplicate cache
    sys.version = version_bak # Restore modified version string
except ValueError: # Catch .index() method not finding a pipe
    pass

您需要將此代碼放在將要執(zhí)行的位置 conda 有機(jī)會(huì)因異常而失敗.不確定最好的地方是什么,但您可以嘗試使用 conda/cli/main.pyconda/api.pyconda/connection.py.

You need to put this code somewhere where it will be executed before conda has a chance to fail with exception. Not sure what the best place would be, but you could try it with conda/cli/main.py, conda/api.py or conda/connection.py.

這篇關(guān)于ValueError:使用 conda 命令后無法解析 CPython sys.version的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時(shí)出現(xiàn)問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節(jié)點(diǎn))
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應(yīng)并將元素值存儲(chǔ)在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標(biāo)記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對(duì)象)
主站蜘蛛池模板: 免费国产视频在线观看 | 欧洲免费视频 | 国产免费拔擦拔擦8x高清 | 国产乱码精品一区二区三区中文 | 日本久久网| 青青草av在线播放 | 国产免费av在线 | 牛牛热在线视频 | 狠狠av| 美国十次成人欧美色导视频 | 欧美一区二区二区 | 日韩成人在线免费视频 | 久久精品91 | 日韩在线视频精品 | 国产精品久久久久一区二区 | 91久久视频| 精品伊人久久 | 激情欧美日韩一区二区 | 精品欧美一区二区三区久久久 | www.激情.com| 精品三区 | 国产亚洲精品综合一区 | 亚洲成人激情在线观看 | 波多野结衣精品在线 | 九九热九九 | 啪啪免费网| 亚洲一区有码 | 丁香久久 | 亚洲综合一区二区三区 | 性高湖久久久久久久久 | 久久av网站 | 国产真实乱对白精彩久久小说 | 欧美精品一区二区在线观看 | 欧美日韩成人在线 | 国产高清久久久 | 一区二区三区视频 | 中文字幕日韩三级 | 黑人巨大精品欧美一区二区免费 | 91久久久久久久久久久久久 | 色狠狠一区 | 99免费在线视频 |