2015-11-10 86 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 

你准备好了!