简体   繁体   English

在没有sudo的情况下安装numpy

[英]Installing numpy without sudo

I am trying to install numpy on a remote host where I have no admin rights. 我试图在我没有管理员权限的远程主机上安装numpy。 I have sucessfully installed Python 2.7 and pip inside a virtualenv ,and can use pip to install trivial things like pip install Markdown . 我成功安装了Python 2.7并在virtualenv中使用pip,并且可以使用pip来安装像pip install Markdown这样的小事。 But if I pip install numpy or scipy, it errors on SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel. 但是,如果我pip install numpy或scipy,它在SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.出错SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel. SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel. I do not have rights to sudo apt-get or apt-get, so can not do sudo apt-get install python27-devel or sudo apt-get install python-devel . 我没有sudo apt-get或apt-get的权限,所以不能做sudo apt-get install python27-develsudo apt-get install python-devel I wanted to build from source so that I could use the option --user but the source is a .deb file and building it requires even more things I have to apt-get. 我想从源代码构建,以便我可以使用选项--user但是源代码是一个.deb文件,并且构建它需要更多我需要的东西。 I tried contacted the admin but I am advised to keep my own installations in my own local environment. 我尝试联系管理员,但我建议将自己的安装保存在我自己的本地环境中。 What should I do? 我该怎么办? The OS system is Ubuntu 14.04 LTS. OS系统是Ubuntu 14.04 LTS。

The reason for the admins answer is simple. 管理员回答的原因很简单。 Ubuntu also uses python for internal scripts. Ubuntu还将python用于内部脚本。 So the admin will not update or change the python installation if you need a more recent version of a package. 因此,如果您需要更新版本的软件包,管理员将不会更新或更改python安装。

This is what I would try: 这是我会尝试的:

  1. Compile source of python 2.7 yourself and install it in your preferred path in your home directory. 自己编译python 2.7的源代码并将其安装在主目录中的首选路径中。 This way you always have all needed headers. 这样你总是拥有所有需要的标题。 Put the interpreter into your PATH. 将解释器放入PATH。

(Optional) Set PYTHONUSERHOME to your local python site packages (可选)将PYTHONUSERHOME设置为本地python站点包

  1. Install virtualenv package via pip 通过pip安装virtualenv包
  2. Setup virtualenv envirnoment for numpy etc... 设置virtualenv envirnoment为numpy等...

(Optional) 4. Build Blas libraries eg OpenBlas in your home (可选)4。在家中构建Blas库,例如OpenBlas

  1. Install cython in virtualenv ... and probably some more packages needed for numpy 在virtualenv中安装cython ......可能还需要更多numpy所需的软件包
  2. Install numpy scipy in the virtualenv with the correct settings BLAS libraries settings 使用正确设置BLAS库设置在virtualenv中安装numpy scipy

If you use your own python installation, the virtualenv is not really necessary. 如果您使用自己的python安装,virtualenv并不是必需的。 So you might want to omit that. 所以你可能想省略它。 You just need to make sure that your python interpreter is always first to be found. 您只需要确保始终首先找到您的python解释器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM