简体   繁体   English

Anaconda安装到主目录

[英]Anaconda installation to home directory

I have set up a SSH connection to a remote server. 我已经建立了与远程服务器的SSH连接。 I want to run some of my python programs on it so am having to download all the modules I had been using. 我想在其上运行我的一些python程序,因此我必须下载我一直在使用的所有模块。

I just downloaded Ananconda (I don't have root access so installed it in ~) and added ~/anaconda/bin to my PATH. 我刚刚下载了Ananconda(我没有root权限,所以在〜中安装了它)并在我的PATH中添加了〜/ anaconda / bin。 However when I try import numpy in Python, it says the module is not found. 但是,当我尝试在Python中import numpy时,它表示找不到该模块。 How do I fix this? 我该如何解决?

You might be running the wrong version of Python. 您可能正在运行错误的Python版本。

To check, use which -a python 要检查,请使用which -a python

james@bodacious:~$which -a python
/usr/bin/python
james@bodacious:~$

In my case, I'm running the version from /usr/bin/python, and that's the only version found in my $PATH. 在我的情况下,我正在运行/ usr / bin / python中的版本,这是我的$ PATH中找到的唯一版本。 You should see the version from ~/anaconda/bin in your list as well, and for it to be run when you type python it needs to be at the top. 您应该在列表中看到来自〜/ anaconda / bin的版本,并且当您键入python时它要运行它需要位于顶部。

If it's not, you can check your $PATH and, if necessary, add ~/anaconda/bin to the front of it. 如果不是,你可以查看你的$ PATH,并在必要时在它的前面添加~/anaconda/bin

james@bodacious:~$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/james/bin
james@bodacious:~$PATH=~/anaconda/bin:$PATH
james@bodacious:~$echo $PATH
/Users/james/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/james/bin
james@bodacious:~$

I haven't any Fedora/Redhat systems handy, but I believe you can: 我没有任何Fedora / Redhat系统,但我相信你可以:

yum install numpy

HTH HTH

You've said that all you really want is to be able to use numpy - based on that, using anaconda is probably overkill. 你已经说过你真正想要的就是能够使用numpy - 基于此,使用anaconda可能有点过分。

It sounds as though what you're really asking is "Since I don't have root access and can't install system packages, how can I set up a python environment in my home dir that has what I need?" 听起来好像你真正问的是“由于我没有root访问权限且无法安装系统软件包,我如何在我的家庭目录中设置一个具有我需要的python环境?”

This sounds like a job for... Super Grover! 这听起来像...超级格罗弗! no wait, I meant virtualenv. 没有等待,我的意思是virtualenv。

Hopefully your system will already have virtualenv installed for you. 希望您的系统已经为您安装了virtualenv。 If it does, it's fairly simple for you to create your own environment with your own set of packages: 如果是这样,使用您自己的一组包创建自己的环境相当简单:

james@bodacious:~$mkdir venv/
james@bodacious:~$cd venv/
james@bodacious:venv$virtualenv .
New python executable in ./bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
james@bodacious:venv$source bin/activate
(venv)james@bodacious:venv$pip install numpy
Downloading/unpacking numpy
  Downloading numpy-1.7.1.zip (3.1MB): 3.1MB downloaded

Once that completes, you'll have your own copy of numpy which you can access in this environment just by using cd venv; source bin/activate 完成后,您将拥有自己的numpy副本,只需使用cd venv; source bin/activate即可在此环境中访问cd venv; source bin/activate cd venv; source bin/activate to set your $PATH and $PYTHONPATH to point at your custom install. cd venv; source bin/activate将$ PATH和$ PYTHONPATH设置为指向自定义安装。

If you don't already have virtualenv installed things get more tricky.... 如果你还没有安装virtualenv东西变得更棘手......

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

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