pylearn2 PATH变量

时间:2015-11-10 06:09:07

标签: python macos variables path environment

令人惊讶的是,关于此的文档或教程很少。

我想在Mac OSX 10.11.1上运行pylearn2。

根据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"

然后跑

source ~/.bashrc

由于它仍然抛出异常,我做了一些研究,发现我必须将.profile文件放入.bash_profile。所以我将这一行添加到.bash_profile:

#.profile
source ~/.profile

但结果仍然相同:(

其他信息

根据installation guide说我应该在路径envoirement中添加另一个信息,但我无法理解哪一个特别。

我系统中的隐藏文件

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

2 个答案:

答案 0 :(得分: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。)打开包装

你将得到一个&#34; cifar-10-batches-py&#34;夹

4。)包裹&#34; cifar-10-batches-py&#34;在&#34; cifar-10&#34;夹

5.)放入&#34; cifar-10&#34;文件夹到/ pylearn2 / datasets

包含cifar-10文件的最终路径应为:

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

你准备好了!

答案 1 :(得分:0)

存在下载脚本:

https://github.com/lisa-lab/pylearn2/blob/master/pylearn2/scripts/datasets/download_cifar10.sh

您是否正确下载了Pylearn2?你错误地删除了文件吗?