如何安装适用于Python的yaml软件包?

本文介绍了如何在Python 2.7(Debian Wheezy)环境中安装yaml软件包。推荐使用pip安装PyYAML,但可能需要先安装pip。在某些情况下,可能还需要libyaml库。文章还提到了其他YAML实现,如Syck和ruamel.yaml,但PyYAML是最推荐的选择。
摘要由CSDN通过智能技术生成

本文翻译自:How do I install the yaml package for Python?

I have a Python program that uses YAML. 我有一个使用YAML的Python程序。 I attempted to install it on a new server using pip install yaml and it returns the following: 我尝试使用pip install yaml将其安装在新服务器上,并且返回以下内容:

$ sudo pip install yaml
Downloading/unpacking yaml
  Could not find any downloads that satisfy the requirement yaml
No distributions at all found for yaml
Storing complete log in /home/pa/.pip/pip.log

How do I install the yaml package for Python? 如何安装适用于Python的yaml软件包? I'm running Python 2.7. 我正在运行Python 2.7。 (OS: Debian Wheezy) (作业系统:Debian Wheezy)


#1楼

参考:https://stackoom.com/question/xq62/如何安装适用于Python的yaml软件包


#2楼

pip install pyyaml

If you don't have pip, run easy_install pip to install pip, which is the go-to package installer - Why use pip over easy_install? 如果没有pip,请运行easy_install pip来安装pip,这是必备的软件包安装程序- 为什么在easy_install上使用pip? . If you prefer to stick with easy_install, then easy_install pyyaml 如果您喜欢坚持使用easy_install,则easy_install pyyaml


#3楼

You could try the search feature in pip, 您可以尝试使用点子搜索功能,

$ pip search yaml

which looks for packages in PyPI with yaml in the short description. 它在简短说明中使用yaml在PyPI中查找软件包。 That reveals various packages, including PyYaml, yamltools, and PySyck, among others (Note that PySyck docs recommend using PyYaml, since syck is out of date). 这揭示了各种软件包,包括PyYaml,yamltools和PySyck等(请注意, PySyck文档建议使用PyYaml,因为syck已过时)。 Now you know a specific package name, you can install it: 现在您知道了特定的软件包名称,可以安装它:

$ pip install pyyaml

If you want to install python yaml system-wide in linux, you can also use a package manager, like aptitude or yum : 如果要在linux系统范围内安装python yaml,还可以使用软件包管理器,例如aptitudeyum

$ sudo apt-get install python-yaml
$ sudo yum install python-yaml

#4楼

Update: Nowadays installing is done with pip, but libyaml is still required to build the C extension (on mac): 更新:如今,安装已通过pip完成,但仍需要libyaml来构建C扩展(在Mac上):

brew install libyaml
python -m pip install pyyaml

Outdated method : 过时的方法

For MacOSX (mavericks), the following seems to work: 对于MacOSX(小牛),以下方法似乎有效:

brew install libyaml
sudo python -m easy_install pyyaml

#5楼

pip install PyYAML

如果找不到libyaml或编译的PyYAML可以在Mavericks上不使用它。


#6楼

There are three YAML capable packages. 有三个支持YAML的软件包。 Syck ( pip install syck ) which implements the YAML 1.0 specification from 2002; Syck( pip install syck ),从2002年开始实施YAML 1.0规范; PyYAML ( pip install pyyaml ) which follows the YAML 1.1 specification from 2004; PyYAML( pip install pyyaml ),遵循2004年的YAML 1.1规范; and ruamel.yaml which follows the latest (YAML 1.2, from 2009) specification. ruamel.yaml遵循最新的规范(从2009年开始使用YAML 1.2)。

You can install the YAML 1.2 compatible package with pip install ruamel.yaml or if you are running a modern version of Debian/Ubuntu (or derivative) with: 您可以使用pip install ruamel.yaml安装YAML 1.2兼容软件包,或者如果您运行的是Debian / Ubuntu(或衍生版本)的现代版本,请执行以下操作:

sudo apt-get install python-ruamel.yaml
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值