9

I am going through this post Numpy, Scipy, and Pandas - Oh My!, installing some python packages, but got stuck at the line for installing Pandas:

pip install -e git+https://github.com/pydata/pandas#egg=pandas

I changed 'wesm' to 'pydata' for the latest version, and the only other difference to the post is that I'm using pythonbrew.

I found this post, related to the error, but where is the Makefile for bz2 mentioned in the answer? Is there another way to resolve this problem?

Any help would be much appreciated. Thanks.

4

3 回答 3

20

您需要构建具有 BZIP2 支持的 python。

在构建 python 之前安装以下包:

  • 红帽/Fedora/CentOS:yum install bzip2-devel
  • Debian/Ubuntu:sudo apt-get install libbz2-dev

提取python tarball。然后

configure;
make;
make install

pip使用新的 python安装。

选择:

使用 yum 或 apt 安装二进制 python 发行版,该发行版是使用 BZIP2 支持构建的。

另请参阅:ImportError: No module named bz2 for Python 2.7.2

于 2014-03-12T09:02:18.400 回答
10

我在互联网上花了很多时间,到处都得到了部分答案。这是您需要执行的操作才能使其正常工作。遵循每一步。

  1. sudo apt-get install libbz2-dev感谢Freek Wiekmeijer
    现在您还需要使用 bz2 构建 python。以前安装的 python 不起作用。为此,请执行以下操作:

  2. 从https://www.python.org/downloads/source/下载稳定的 python 版本,然后提取Gzipped 源 tarball文件。您可以使用wget https://python-tar-file-link.tgz下载并tar -xvzf python-tar-file.tgz在当前目录中提取它

  3. 进入提取的文件夹,然后一次运行以下命令

    • ./configure
    • make
    • make install
  4. 这将使用您之前安装的 bz2 构建一个 python 文件

  5. 由于这个python没有安装pip,想法是用上面构建的python创建一个虚拟环境,然后使用以前安装的pip安装pandas

  6. 您将python在同一目录中看到文件。只需创建一个虚拟环境。

    • ./python -m env myenv(在同一目录或外部创建 myenv 是您的选择)
    • source myenv/bin/activate(激活虚拟环境)
    • pip install pandas(在当前环境安装pandas)
  7. 而已。现在有了这个环境,你应该可以正确使用 pandas 了。

于 2020-01-24T13:48:07.467 回答
0

pyenv

我注意到使用源代码安装 Python 需要很长时间(我在 i7 上进行安装:/);尤其是makemake test...

一个更简单和更短的解决方案是使用安装另一个版本的 Python(我使用 Python 3.7.8) ,使用这些步骤pyenv安装它。

它不仅解决了在同一系统上使用多个 Python 实例的问题,而且还维护了我的虚拟环境virtualenvwrapper(这在我新设置的 ubuntu-20.04 上变成了错误)。

于 2020-09-15T14:08:37.320 回答