6

I have installed Anaconda package on a server as a user account, then I installed keras by conda install keras,but after installation, when I run import keras, it raised no module names keras,anyone can help? thanks very much!

K.Wanter
  • 969
  • 3
  • 14
  • 30
  • Works for me. What OS are you on? What Python version? Do you use a conda environment? – Mike Müller Jan 01 '17 at 13:03
  • I'm running on remote server using SSH, the server is UNIX, previously there is already python 2.7 installed on the server, what do you mean use a conda environment? – K.Wanter Jan 01 '17 at 13:08
  • Likely that you use a different Python than in which you installed the library. Try `which -a python` to see what you got. – Mike Müller Jan 01 '17 at 13:11
  • the outcome of `which -a python` is `/bin/python`, my anaconda is installed in `/projdata3/info_fil/wangtao/conda` – K.Wanter Jan 01 '17 at 13:14
  • What if you try: `conda install -c conda-forge keras` – Sahar May 31 '17 at 21:40

2 Answers2

6

One solution could be creating a conda environment:

conda create -n keras python=3.5

Now activate it:

conda activate keras

and install keras:

(keras)$ conda install keras

Try if it works:

(keras)$ python
>>> import keras
Mike Müller
  • 82,630
  • 20
  • 166
  • 161
  • then I tried `which activate`, it gives `/projdata3/info_fil/wangtao/conda/bin/activate`, then I cd to `/projdata3/info_fil/wangtao/conda/bin` and run `source activate keras` again, this time it raised `BASH_VERSION: Undefined variable` – K.Wanter Jan 01 '17 at 13:52
  • 1
    Are using a shell that is not `bash`? Change to `bash` – Mike Müller Jan 01 '17 at 14:40
0

Once creating the Conda environment, use the command below to list available environment:

conda info -e

Once activate your conda environment, you can try to install Keras by

pip install keras==version_your_desired.

Then use

pip freeze

to check the version.

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
Hong
  • 526
  • 6
  • 21