如何为Python安装yaml包?

时间:2022-04-25 11:24:06

I have a Python program that uses YAML. I attempted to install it on a new server using pip install yaml and it returns the following:

我有一个使用YAML的Python程序。我尝试使用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? I'm running Python 2.7. (OS: Debian Wheezy)

如何为Python安装yaml包?我运行Python 2.7。(操作系统:Debian老生常谈的)

8 个解决方案

#1


349  

You could try the search feature in pip,

你可以试试pip的搜索功能,

$ pip search yaml

which looks for packages in PyPI with yaml in the short description. That reveals various packages, including PyYaml, yamltools, and PySyck, among others (Note that PySyck docs recommend using PyYaml, since syck is out of date). Now you know a specific package name, you can install it:

在简短的描述中查找带有yaml的PyPI包。这揭示了各种包,包括PyYaml、yamltools和PySyck等(注意PySyck文档推荐使用PyYaml,因为syck已经过时了)。现在您知道了一个特定的包名,您可以安装它:

$ 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系统,您还可以使用一个包管理器,比如资质或yum:

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

#2


69  

pip install pyyaml

pip安装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?. If you prefer to stick with easy_install, then easy_install pyyaml

如果您没有pip,请运行easy_install pip来安装pip,这是go-to包安装程序——为什么要使用pip而不是easy_install?如果您更喜欢使用easy_install,那么easy_install pyyaml

#3


36  

For MacOSX (mavericks), the following seems to work:

对于MacOSX(小牛队)来说,下面这些似乎是有用的:

brew install libyaml
sudo python -m easy_install pyyaml

#4


11  

pip install PyYAML

If libyaml is not found or compiled PyYAML can do without it on Mavericks.

如果利比亚没有被发现或编译的PyYAML可以在没有它的Mavericks。

#5


5  

There are three YAML capable packages. Syck (pip install syck) which implements the YAML 1.0 specification from 2002; PyYAML (pip install pyyaml) which follows the YAML 1.1 specification from 2004; and ruamel.yaml which follows the latest (YAML 1.2) specification.

有三个YAML能力包。Syck (pip安装Syck),从2002年开始执行YAML 1.0规范;PyYAML (pip安装PyYAML),从2004年开始遵循YAML 1.1规范;和ruamel。yaml遵循最新的(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安装ruamel安装YAML 1.2兼容的包。如果你正在运行一个现代版本的Debian/Ubuntu(或衍生物):

sudo apt-get install python-ruamel.yaml

#6


2  

Debian-based systems:

Debian-based系统:

$ sudo aptitude install python-yaml

安装python-yaml

or newer for python3

或更新python3

$ sudo aptitude install python3-yaml

$ sudo aptitude install python3-yaml

#7


0  

For me, installing development version of libyaml did it.

对我来说,安装开发版本的利比亚计算机公司就是这样做的。

yum install libyaml-devel         #centos
apt-get install libyaml-dev       # ubuntu

#8


-1  

Tested on MAC OS X High Sierra, Python 3.6.4

在MAC OS X High Sierra, Python 3.6.4上进行测试

$ brew install libyaml
Warning: libyaml 0.1.7 is already installed and up-to-date
To reinstall 0.1.7, run `brew reinstall libyaml`

$ sudo python -m easy_install pyyaml
Password:
Searching for pyyaml
Reading https://pypi.python.org/simple/pyyaml/
Downloading https://files.pythonhosted.org/packages/6b/f0/a0250248ea260d55748fff586d89a32afbb22656f4498b08d2636a48d4ec/PyYAML-3.12.zip#sha256=5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7
Best match: PyYAML 3.12
Processing PyYAML-3.12.zip
Writing /tmp/easy_install-gjemt5iq/PyYAML-3.12/setup.cfg
Running PyYAML-3.12/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gjemt5iq/PyYAML-3.12/egg-dist-tmp-u2necc2y
In file included from ext/_yaml.c:271:
....................................................................................................................................................................................

$ python
Python 3.6.4 (default, Mar  1 2018, 18:36:50)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> exit();

$

#1


349  

You could try the search feature in pip,

你可以试试pip的搜索功能,

$ pip search yaml

which looks for packages in PyPI with yaml in the short description. That reveals various packages, including PyYaml, yamltools, and PySyck, among others (Note that PySyck docs recommend using PyYaml, since syck is out of date). Now you know a specific package name, you can install it:

在简短的描述中查找带有yaml的PyPI包。这揭示了各种包,包括PyYaml、yamltools和PySyck等(注意PySyck文档推荐使用PyYaml,因为syck已经过时了)。现在您知道了一个特定的包名,您可以安装它:

$ 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系统,您还可以使用一个包管理器,比如资质或yum:

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

#2


69  

pip install pyyaml

pip安装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?. If you prefer to stick with easy_install, then easy_install pyyaml

如果您没有pip,请运行easy_install pip来安装pip,这是go-to包安装程序——为什么要使用pip而不是easy_install?如果您更喜欢使用easy_install,那么easy_install pyyaml

#3


36  

For MacOSX (mavericks), the following seems to work:

对于MacOSX(小牛队)来说,下面这些似乎是有用的:

brew install libyaml
sudo python -m easy_install pyyaml

#4


11  

pip install PyYAML

If libyaml is not found or compiled PyYAML can do without it on Mavericks.

如果利比亚没有被发现或编译的PyYAML可以在没有它的Mavericks。

#5


5  

There are three YAML capable packages. Syck (pip install syck) which implements the YAML 1.0 specification from 2002; PyYAML (pip install pyyaml) which follows the YAML 1.1 specification from 2004; and ruamel.yaml which follows the latest (YAML 1.2) specification.

有三个YAML能力包。Syck (pip安装Syck),从2002年开始执行YAML 1.0规范;PyYAML (pip安装PyYAML),从2004年开始遵循YAML 1.1规范;和ruamel。yaml遵循最新的(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安装ruamel安装YAML 1.2兼容的包。如果你正在运行一个现代版本的Debian/Ubuntu(或衍生物):

sudo apt-get install python-ruamel.yaml

#6


2  

Debian-based systems:

Debian-based系统:

$ sudo aptitude install python-yaml

安装python-yaml

or newer for python3

或更新python3

$ sudo aptitude install python3-yaml

$ sudo aptitude install python3-yaml

#7


0  

For me, installing development version of libyaml did it.

对我来说,安装开发版本的利比亚计算机公司就是这样做的。

yum install libyaml-devel         #centos
apt-get install libyaml-dev       # ubuntu

#8


-1  

Tested on MAC OS X High Sierra, Python 3.6.4

在MAC OS X High Sierra, Python 3.6.4上进行测试

$ brew install libyaml
Warning: libyaml 0.1.7 is already installed and up-to-date
To reinstall 0.1.7, run `brew reinstall libyaml`

$ sudo python -m easy_install pyyaml
Password:
Searching for pyyaml
Reading https://pypi.python.org/simple/pyyaml/
Downloading https://files.pythonhosted.org/packages/6b/f0/a0250248ea260d55748fff586d89a32afbb22656f4498b08d2636a48d4ec/PyYAML-3.12.zip#sha256=5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7
Best match: PyYAML 3.12
Processing PyYAML-3.12.zip
Writing /tmp/easy_install-gjemt5iq/PyYAML-3.12/setup.cfg
Running PyYAML-3.12/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gjemt5iq/PyYAML-3.12/egg-dist-tmp-u2necc2y
In file included from ext/_yaml.c:271:
....................................................................................................................................................................................

$ python
Python 3.6.4 (default, Mar  1 2018, 18:36:50)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> exit();

$