2015-11-10 89 views
0

這裏有令人驚訝的文檔或教程很少。pylearn2 PATH變量

我想在我的Mac OSX 10.11.1上運行pylearn2。

Acoording到the tutorial我應該在第一此行運行:

cd pylearn/pylearn2/scripts/tutorials/grbm_smd/ 
python make_dataset.py 

然而,腳本失敗與此異常:

Traceback (most recent call last): 
    File "/Users/username/python/pylearn2/pylearn2/utils/string_utils.py", line 53, in preprocess 
    else os.environ[varname]) 
    File "/Users/username/anaconda/lib/python3.4/os.py", line 633, in __getitem__ 
    raise KeyError(key) from None 
KeyError: 'PYLEARN2_DATA_PATH' 

The above exception was the direct cause of the following exception: 

Traceback (most recent call last): 
    File "make_dataset.py", line 27, in <module> 
    train = cifar10.CIFAR10(which_set="train") 
    File "/Users/username/python/pylearn2/pylearn2/datasets/cifar10.py", line 71, in __init__ 
    string_utils.preprocess('${PYLEARN2_DATA_PATH}'), 
    File "/Users/username/python/pylearn2/pylearn2/utils/string_utils.py", line 56, in preprocess 
    reraise_as(NoDataPathError()) 
    File "/Users/username/python/pylearn2/pylearn2/utils/exc.py", line 90, in reraise_as 
    six.reraise(type(new_exc), new_exc, orig_exc_traceback) 
    File "/Users/username/anaconda/lib/python3.4/site-packages/theano/compat/six.py", line 321, in reraise 
    raise value.with_traceback(tb) 
    File "/Users/username/python/pylearn2/pylearn2/utils/string_utils.py", line 53, in preprocess 
    else os.environ[varname]) 
    File "/Users/username/anaconda/lib/python3.4/os.py", line 633, in __getitem__ 
    raise KeyError(key) from None 
pylearn2.utils.exc.NoDataPathError: You need to define your PYLEARN2_DATA_PATH environment variable. If you are 
using a computer at LISA, this should be set to /data/lisa/data. 

Platform-specific instructions for setting environment variables: 

Linux 
===== 
On most linux setups, you can define your environment variable by adding this 
line to your ~/.bashrc file: 

export PYLEARN2_VIEWER_COMMAND="eog --new-instance" 

*** YOU MUST INCLUDE THE WORD "export". DO NOT JUST ASSIGN TO THE ENVIRONMENT VARIABLE *** 
If you do not include the word "export", the environment variable will be set 
in your bash shell, but will not be visible to processes that you launch from 
it, like the python interpreter. 

Don't forget that changes from your .bashrc file won't apply until you run 

source ~/.bashrc 

or open a new terminal window. If you're seeing this from an ipython notebook 
you'll need to restart the ipython notebook, or maybe modify os.environ from 
an ipython cell. 

Mac OS X 
======== 

Environment variables on Mac OS X work the same as in Linux, except you should 
modify and run the "source" command on ~/.profile rather than ~/.bashrc. 


Original exception: 
    KeyError: PYLEARN2_DATA_PATH 

我插入從異常以下信息到〜/ .profile文件

export PYLEARN2_VIEWER_COMMAND="eog --new-instance" 

and ran

source ~/.bashrc 

因爲它仍然拋出了一個異常,我做了一些研究,發現我必須把.profile文件放到.bash_profile文件中。所以我說這行對.bash_profile:

#.profile 
source ~/.profile 

但是結果還是一樣:(

信息

按照installation guide說我應該添加其他信息的路徑但我不明白其中的具體情況。

我係統中的隱藏文件

  • .bash_history的
  • 的.bash_profile
  • 的.bash_profile-anaconda.bak
  • .bash_sessions
  • 的.config
  • .ipython
  • 。本地
  • 的.profile
  • .python_history
  • .theano
  • .vminfo

回答

0

通過代碼去自己之後,我已經找到了解決方案。源代碼中存在一個缺失download_cifar10.sh腳本的錯誤。另外教程缺少必要的PATH變量。

指令

1)中設定的變量PATH

export PYLEARN2_VIEWER_COMMAND="eog --new-instance" 
export PYLEARN2_DATA_PATH=/YOURPATHTOHERE/pylearn2/datasets 

2.)download cifar-10 (python version)

3。)解壓縮

你會得到一個 「CIFAR-10批次-PY」 文件夾

4)總結 「CIFAR-10批次-PY」 在 「CIFAR-10」 文件夾

5)將 「CIFAR-10」 文件夾放入/ pylearn2 /數據集

的最終路徑包含CIFAR-10文件應該是:

../pylearn2/datasets/cifar-10-batches-py/cifar-10 

你準備好了!