python - 尝试在某个目录中运行鼻子测试时出错〜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。这似乎是一个环境问题,但如果不是,请指出正确的方向。谢谢。
解决方案
推荐阅读
- javascript - 使用 jQuery 创建移动菜单
- angular - Angular / 在选择时对每次更改发送另一个获取请求
- node.js - 如何将 Hashmap 插入 MongoDB 文档?
- python - 如何将元素添加到 numpy ndarray
- github - Github desltop - 如何为特定的仓库设置外部编辑器?
- python - csv.writer.writerow 字段中的逗号未正确写入
- c++ - 名称后跟 :: 必须是类或命名空间名称
- kubernetes - 为什么注释:在入口服务中需要重写目标
- c++ - 没有 SMBv1 的 WINAPI 网络发现
- php - 语法错误:JSON.parse?