将模块添加到 Python3 [英] Adding modules to Python3

查看:45
本文介绍了将模块添加到 Python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用库 matplotlib,但无法使用 python3.不过,我找到的 python 2.7.3 解释器没有问题.我需要采取哪些步骤才能让 python3 访问这个库?

I am trying to use the library matplotlib, but can't get it to work with python3. The python 2.7.3 interpreter I have finds it without a problem though. What steps do I need to take for python3 to have access to this library?

推荐答案

为了处理你的 Python 包,我建议你使用 pip 而不是你的 OS 包管理器.

To handle your Python packages, I suggest you rather use pip than your OS package manager.

要安装 pip,只需按照说明.

To install pip, just follow the instructions.

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py

应该够了.

如果你路径上的python是2.x版本,请务必使用python3命令

Be sure to use python3 command if the python on your path is version 2.x

安装 pip 后,您将能够通过运行 Pypi 下载和安装软件包/p>

After having install pip, you will be able to download and install the packages from Pypi by running

pip install PACKAGE_NAME

例如,对于 matplotlib

so for instance, for matplotlib

pip install matplotlib

如果已经安装了 Python2 的 pip,命令可能是 pip3pip-3.x 来安装 Python3 的包.

If pip is already installed for Python2, the command may be pip3 or pip-3.x to install packages for Python3.

如果您在安装 matplotlib 时遇到错误,请确保您拥有编译它所需的软件包.我想在 Ubuntu 上

If you have errors while installing matplotlib, make sure that you have the necessary packages to compile it. On Ubuntu I suppose

sudo apt-get install build-essential

不过对于基本安装来说应该足够了.

should be enough for a basic installation though.

这篇关于将模块添加到 Python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆