首页 > 解决方案 > 尝试在某个目录中运行鼻子测试时出错〜PyThreadState_Get:没有当前线程

问题描述

我正在尝试使用/opt/moose/miniconda/bin/python环境(由我的工作设置的环境)来处理一些单独的代码,并且在尝试使用鼻子模块运行测试时遇到错误。

回到我的问题开始的地方,我在运行时收到了这个错误:

pip install nose

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/moose/miniconda/lib/python2.7/site-packages/nose'
Consider using the `--user` option or check the permissions.

所以我然后跑了

pip install nose --user

The scripts nosetests and nosetests-2.7 are installed in '~/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

所以我然后添加到我的 ~/.bashrc 文件中

export PATH=$PATH:~/.local/bin

现在,当我在我的主目录中打开一个 python 解释器时,我可以成功运行:

Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nose
>>> nose.main()


----------------------------------------------------------------------
Ran 0 tests in 0.002s


OK

但是,当我移动到我想要实际运行测试的目录时,我得到:

$ cd Documents/projects/neml
$ python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nose
>>> nose.main()

Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

知道为什么会出现此错误,看来我在两个目录中都运行相同的 python。这似乎是一个环境问题,但如果不是,请指出正确的方向。谢谢。

标签: pythonanacondanose

解决方案


推荐阅读