为了自动测试我的项目,我试着运行毒物测试。我的毒理文件很简单:
[tox]
envlist = py3
[testenv]
deps = pytest
commands =
pytest --doctest-modules我还有一个requirements.txt文件,它定义了所需的模块:
cmake
osqp
numpy
cvxpy
networkx
matplotlib和一个setup.py文件:
from setuptools import setup, find_packages
...
requirements = ["numpy","cvxpy","networkx","matplotlib"]
...
setup(
name='fairpy',
version='1.0',
description=...,
packages=find_packages(),
install_requires=requirements,
...
)但是,当我从终端运行毒性测试时,会发现一个错误,即找不到模块numpy:
GLOB sdist-make: /mnt/d/Dropbox/ariel/fairpy/setup.py
py3 inst-nodeps: /mnt/d/Dropbox/ariel/fairpy/.tox/.tmp/package/1/fairpy-1.0.zip
py3 installed: attrs==19.3.0,fairpy==1.0,more-itertools==8.1.0,packaging==20.1,pluggy==0.13.1,py==1.8.1,pyparsing==2.4.6,pytest==5.3.4,six==1.14.0,wcwidth==0.1.8
py3 run-test-pre: PYTHONHASHSEED='188600482'
py3 run-test: commands[0] | pytest --doctest-modules
========================================================== test session starts ==========================================================
platform linux -- Python 3.8.1, pytest-5.3.4, py-1.8.1, pluggy-0.13.1
cachedir: .tox/py3/.pytest_cache
rootdir: /mnt/d/Dropbox/ariel/fairpy
collected 0 items / 20 errors
================================================================ ERRORS =================================================================
__________________________________________________ ERROR collecting Deng_Qi_Saberi.py ___________________________________________________
Deng_Qi_Saberi.py:13: in <module>
from agents import *
agents.py:10: in <module>
import numpy as np
E ModuleNotFoundError: No module named 'numpy'
...我安装了numpy --在我的python 3.8.1终端中,我可以毫无问题地导入numpy。
我的毒理怎么了?
发布于 2020-05-01 09:29:40
第一,
我安装了numpy -在我的python3.8.1终端中,我可以毫无问题地导入numpy。
tox在运行时会创建一个虚拟环境,所以在您的计算机原始解释器上安装numpy并不重要。
第二,如果您想要安装需求文件,必须将deps = -rrequirements.txt添加到tox.ini中。您也可以手动添加numpy作为依赖项。
第三,在某些情况下,tox有一些依赖项跟踪问题。尝试运行tox -r以强制tox重新创建其环境,并确保setup.py中的"install_requires“部分中提到的numpy。
https://stackoverflow.com/questions/61538080
复制相似问题