本文介绍了使用tox运行python单元测试时遇到问题-已安装模块的ImportError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python的新手,正在尝试为此项目运行单元测试: https://github.com/matrix-org/synapse

我正在从项目的顶层运行tox.我收到此错误:exceptions.ImportError:没有名为pymacaroons的模块

但是pymacaroons已经使用pip安装.据我所知,我只有一个版本的python.真的很困在这里.

解决方案

tox创建自己的虚拟环境,并根据tox.ini安装依赖项. pymacaroons未在tox.ini中列出,因此未安装.要安装它,可以在tox.ini中添加pymacaroons(在[testenv]部分,键deps),或者在tox.ini中添加-rrequirements.txt并在requirements.txt中列出pymacaroons.

I am new to python and am trying to run unit tests for this project:https://github.com/matrix-org/synapse

I am running tox from the top level of the project. I get this error:exceptions.ImportError: No module named pymacaroons

But pymacaroons is already installed using pip. To my knowledge, I only have one version of python. Really stumped here.

解决方案

tox creates its own virtual environments and installs dependencies according to tox.ini. pymacaroons is not listed in tox.ini hence it's not installed. To install it either add pymacaroons to tox.ini (section [testenv], key deps) or add -rrequirements.txt to tox.ini and list pymacaroons in the requirements.txt.

这篇关于使用tox运行python单元测试时遇到问题-已安装模块的ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 11:30