Conda环境错误的pyyaml版本

时间:2019-12-17 13:04:27

标签: python-3.x conda pyyaml

conda list pyyaml

# packages in environment at c:\Anaconda3:
#
# Name                    Version                   Build  Channel
pyyaml                    3.13            py36hfa6e2cd_1001    conda-forge

conda env list

# conda environments:
#
                         C:\Anaconda3
base                     c:\Anaconda3
yaml                  *  c:\Anaconda3\envs\yaml

切换到Yaml环境 activiate yaml

conda list pyyaml

# packages in environment at c:\Anaconda3\envs\yaml:
#
# Name                    Version                   Build  Channel
pyyaml                    5.2              py36he774522_0

使用python在环境yaml中启动Python

Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'

为什么返回3.13而不返回5.2?

更新2019-12-17,14:32

(base) D:\a\buch>
(base) D:\a\buch>conda activate yaml
(yaml) D:\a\buch>
(yaml) D:\a\buch>python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
>>>
(yaml) D:\a\buch>c:\Anaconda3\envs\yaml\python.exe
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
>>> 

1 个答案:

答案 0 :(得分:0)

这是因为默认情况下,在anaconda中,您将处于def infinity(): i=0 while True: i+=1 yield i for i in infinity(): if there_is_a_reason_to_break(i): break 版本为3.13(在您的情况下)的基本环境中。

如果您激活环境pyyaml并检查yaml的版本,则会发现pyyaml的5.2版本

您所遇到的问题是您处于同一基本环境中。请使用以下命令切换到其他环境。

pyyaml

您忘记在conda activate yaml 之前使用conda命令,因此您处于同一基本环境中。

也请遵循此link。 希望对您有帮助。