【问题标题】:How do I install pytest on virtualenv when the python package is installed on the local machine and not in the virtualenv?当 python 包安装在本地机器上而不是 virtualenv 中时,如何在 virtualenv 上安装 pytest?
【发布时间】:2020-05-04 19:29:38
【问题描述】:

这是我尝试在虚拟环境中为 ONNX 框架安装 pytest 和 nbval 时遇到的错误。我的主目录 (~/) 内存有限。当我尝试使用变量 $IPYTHONDIR 更改 IPython 目录路径时,它表明 pytest 中提到的模块丢失 当我在 virtualenv 中运行测试时,我得到以下结果。

platform linux -- Python 3.7.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /local/mnt2/workspace2/Virtual_Env/venv-onnx
plugins: nbval-0.9.5
collected 0 items / 1 error                                                                                                                                                                                                                 

================================================================================================================== ERRORS ===================================================================================================================
_______________________________________________________________________________________________________ ERROR collecting test session _______________________________________________________________________________________________________
lib/python3.7/site-packages/_pytest/config/__init__.py:495: in _importconftest
    return self._conftestpath2mod[key]
E   KeyError: PosixPath('/local/mnt2/workspace2/Virtual_Env/venv-onnx/lib/python3.7/site-packages/IPython/conftest.py')

During handling of the above exception, another exception occurred:
lib/python3.7/site-packages/_pytest/config/__init__.py:501: in _importconftest
    mod = conftestpath.pyimport()
lib/python3.7/site-packages/py/_path/local.py:701: in pyimport
    __import__(modname)
<frozen importlib._bootstrap>:983: in _find_and_load
    ???
<frozen importlib._bootstrap>:967: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:677: in _load_unlocked
    ???
lib/python3.7/site-packages/_pytest/assertion/rewrite.py:152: in exec_module
    exec(co, module.__dict__)
lib/python3.7/site-packages/IPython/conftest.py:69: in <module>
    inject()
lib/python3.7/site-packages/IPython/conftest.py:59: in inject
    builtins._ip = get_ipython()
lib/python3.7/site-packages/IPython/conftest.py:21: in get_ipython
    shell = TerminalInteractiveShell.instance(config=config)
lib/python3.7/site-packages/traitlets/config/configurable.py:412: in instance
    inst = cls(*args, **kwargs)
lib/python3.7/site-packages/IPython/terminal/interactiveshell.py:520: in __init__
    super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
lib/python3.7/site-packages/IPython/core/interactiveshell.py:637: in __init__
    self.init_ipython_dir(ipython_dir)
lib/python3.7/site-packages/IPython/core/interactiveshell.py:737: in init_ipython_dir
    self.ipython_dir = get_ipython_dir()
lib/python3.7/site-packages/traitlets/traitlets.py:585: in __set__
    self.set(obj, value)
lib/python3.7/site-packages/traitlets/traitlets.py:574: in set
    obj._notify_trait(self.name, old_value, new_value)
lib/python3.7/site-packages/traitlets/traitlets.py:1139: in _notify_trait
    type='change',
lib/python3.7/site-packages/traitlets/traitlets.py:1176: in notify_change
    c(change)
lib/python3.7/site-packages/IPython/core/interactiveshell.py:714: in _ipython_dir_changed
    ensure_dir_exists(change['new'])
lib/python3.7/site-packages/IPython/utils/path.py:431: in ensure_dir_exists
    os.makedirs(path, mode=mode)
/usr/lib/python3.7/os.py:223: in makedirs
    mkdir(name, mode)
E   OSError: [Errno 122] Disk quota exceeded: '/usr2/tkavathe/.ipython'

During handling of the above exception, another exception occurred:
lib/python3.7/site-packages/py/_path/common.py:383: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
lib/python3.7/site-packages/py/_path/common.py:435: in gen
    for p in self.gen(subdir):
lib/python3.7/site-packages/py/_path/common.py:435: in gen
    for p in self.gen(subdir):
lib/python3.7/site-packages/py/_path/common.py:435: in gen
    for p in self.gen(subdir):
lib/python3.7/site-packages/py/_path/common.py:424: in gen
    dirs = self.optsort([p for p in entries
lib/python3.7/site-packages/py/_path/common.py:425: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
lib/python3.7/site-packages/_pytest/nodes.py:506: in _recurse
    ihook = self._gethookproxy(dirpath)
lib/python3.7/site-packages/_pytest/nodes.py:487: in _gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
lib/python3.7/site-packages/_pytest/config/__init__.py:473: in _getconftestmodules
    mod = self._importconftest(conftestpath)
lib/python3.7/site-packages/_pytest/config/__init__.py:509: in _importconftest
    raise ConftestImportFailure(conftestpath, sys.exc_info())
E   _pytest.config.ConftestImportFailure: (local('/local/mnt2/workspace2/Virtual_Env/venv-onnx/lib/python3.7/site-packages/IPython/conftest.py'), (<class 'OSError'>, OSError(122, 'Disk quota exceeded'), <traceback object at 0x7f1874042460>))
========================================================================================================== short test summary info ==========================================================================================================
ERROR  - _pytest.config.ConftestImportFailure: (local('/local/mnt2/workspace2/Virtual_Env/venv-onnx/lib/python3.7/site-packages/IPython/conftest.py'), (<class 'OSError'>, OSError(122, 'Disk quota exceeded'), <traceback object at 0x7f1...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================= 1 error in 0.34s ==============================================================================================================

【问题讨论】:

  • 该错误表示您的用户的磁盘空间(配额)不足
  • @jordanm 我知道我的磁盘空间已被超出。但我想知道如何在另一个位置创建临时文件夹,因为我无权访问该用户空间

标签: python linux virtualenv onnx


【解决方案1】:

请清除所有临时文件夹和所有不需要的文件。

您的堆栈跟踪清楚地表明超出了磁盘配额。 磁盘配额是允许您在给定磁盘或位置存储的最大数据量

【讨论】:

  • 您好,我无法更改磁盘空间,也无法删除必要的文件。有没有办法在安装pytest的过程中改变路径?
  • 尝试使用 altinstall
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-27
  • 2017-01-26
  • 2014-02-10
  • 1970-01-01
  • 1970-01-01
  • 2014-12-14
相关资源
最近更新 更多