安装具有aptitude的包时有多个版本的python

在实验室机器上,我不能只是破坏事物,似乎安装了多个版本的
python.

如果我python –version我看到2.7.1.

我已经通过“apt-get install numpy”安装了numpy并且它已经安装了,但是当我尝试导入它时却找不到它.

当我在机器上查找numpy时,我会在/usr/lib/python2.5/site-packages/numpy文件夹中看到它.我认为这是问题… apt-get将它放在2.5版本而不是2.7版本中.

我该如何解决这个问题?有没有办法告诉apt-get我在安装时正在谈论哪个python?或者我是否放弃资质并使用点子或其他东西?

最佳答案 如果要在一台计算机上使用多个版本的python,则应调查
virtualenv.

virtualenv is a tool to create isolated Python environments.

The basic problem being addressed is one of dependencies and versions,
and indirectly permissions. Imagine you have an application that needs
version 1 of LibFoo, but another application requires version 2. How
can you use both these applications? If you install everything into
/usr/lib/python2.7/site-packages (or whatever your platform’s standard
location is), it’s easy to end up in a situation where you
unintentionally upgrade an application that shouldn’t be upgraded.

Or more generally, what if you want to install an application and
leave it be? If an application works, any change in its libraries or
the versions of those libraries can break the application.

Also, what if you can’t install packages into the global site-packages
directory? For instance, on a shared host.

In all these cases, virtualenv can help you. It creates an environment
that has its own installation directories, that doesn’t share
libraries with other virtualenv environments (and optionally doesn’t
access the globally installed libraries either).

这是一个问题with a similar solution.

另外,我使用virtualenvwrapper因为我发现它使管理多个环境的生活变得更加容易.

点赞