本文介绍了切换到其他Python二进制文件后,强制`pip`重新编译以前安装的软件包(numpy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题不仅与我正在使用的一般流程有关,还与我的特定问题有关(我找到了一种解决方法,因此这不是一个亟待解决的问题).

This question is as much a question about my particular problem (which I sort of found a work-around, so it's not a burning issue) as it is about the general process I am using.

我在Ubuntu 14.04上本地安装了Python 2.7.9,并且在其中运行的是virtualenv.一切都与我没有接触过的系统" Python完全分开.

I have Python 2.7.9 installed locally on my Ubuntu 14.04, and I have a virtualenv in which I am running it. Everything is very much separated from the "system" Python, which I am not touching.

一切顺利,安装了我的Python并运行了所有库.例如,我还pip安装了numpy 1.10.1,它编译了一段时间,然后运行良好.

It all started well enough, with my Python installed and all libraries running. For example, I also pip installed numpy 1.10.1, it compiled for a while, then it worked just fine.

问题是,由于无法控制的原因,我不得不在启用ucs4的情况下重建python,即我使用

The problem is that for reasons beyond my control, I had to rebuild the python with ucs4 enabled, that is I installed it using

./configure --enable-unicode=ucs4

这样做之后,我还卸载了所有库并使用pip重新安装了它们.但是,似乎numpy库没有正确卸载,因为这一次它已立即安装,并且当我尝试将numpy导入到新的Python中时,我收到一条错误消息,指示numpy是使用ucs2编译的-启用的Python.

After doing this, I also uninstalled all libraries and reinstalled them using pip. However, it seems that the numpy library was not properly uninstalled because it installed instantly this time, and when I tried to import numpy into my new Python, I got an error message indicating that the numpy was compiled with the ucs2-enabled Python.

由于我随后尝试了pip install numpy==1.9.3,因此该假设非常可靠.安装再次花费了很长时间,并且产生了一个numpy版本,该版本可以在启用ucs4的新Python 上运行.

This hypothesis is pretty solid, since I tried then to pip install numpy==1.9.3. The installation once again took a long time, and it produced a numpy version that works on the new ucs4 enabled Python.


编辑:

我还尝试通过从我的virtualenv site-packages目录中删除numpy来手动删除它.删除后,import numpy会按预期返回ImportError.然后,我重新安装了它(pip install numpy),它又出现了与ucs2相关的相同错误.

I also tried to manually remove numpy by deleting it from my virtualenv site-packages directory. After deleting, import numpy returned an ImportError as expected. I then reinstalled it (pip install numpy) and it came back with the same ucs2-related error.

编辑2 :

我的virtualenv Python看到的完整sys.path

The full sys.path seen by my virtualenv Python is

['',
 '/home/jkralj/.virtualenvs/work/lib/python27.zip',
 '/home/jkralj/.virtualenvs/work/lib/python2.7',
 '/home/jkralj/.virtualenvs/work/lib/python2.7/plat-linux2',
 '/home/jkralj/.virtualenvs/work/lib/python2.7/lib-tk',
 '/home/jkralj/.virtualenvs/work/lib/python2.7/lib-old',
 '/home/jkralj/.virtualenvs/work/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7.9/lib/python2.7',
 '/usr/local/lib/python2.7.9/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7.9/lib/python2.7/lib-tk',
 '/home/jkralj/.virtualenvs/work/lib/python2.7/site-packages']

此外,可能需要提及的是,/usr/local/lib/python2.7.9/安装的python 没有没有安装numpy.

Also, it might be important to mention that the /usr/local/lib/python2.7.9/ installation of python does not have numpy installed.

推荐答案

问题是通过pip卸载numpy(或任何其他麻烦的软件包)然后运行来解决的

The problem is solved by pip uninstalling numpy (or any other troublesome package), then running

pip install numpy --no-cache-dir

防止pip只是简单地进行缓存的安装并重复进行.

to prevent pip from simply taking the cached installation and repeating it.

这篇关于切换到其他Python二进制文件后,强制`pip`重新编译以前安装的软件包(numpy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 19:00