in my django project, I have a an __init__.py
file that imports celery, I suspect this may be causing tox to complain.
/testproj/testproj/ ____init___.py
from .celery import app as celery_app
when I run tox, the tests successfully run, but I see this error.
File "/dir/work/testproj/testproj/celery.py", line 2, in <module>
from celery import Celery
ImportError: cannot import name Celery
mobilereports installed: amqp==1.4.9,anyjson==0.3.3,appdirs==1.4.0,Babel==2.3.4,billiard==3.3.0.23,cached-property==1.3.0,celery==3.1.24
What I find strange is that the import error is above the actual imports where celery gets imported.
Why am I getting this error? Celery is in my requirements.txt
which is being installed by tox as you can see above, so why would I get an import error before the deps actually get installed?
tox.ini
[tox]
envlist = mobilereports
skipsdist = True
[env]
commands = ./runtests.sh
setenv =
DJANGO_SETTINGS_MODULE=testproj.settings
PYTHONPATH={toxinidir}
[base]
deps =
-r{toxinidir}/requirements.txt
[env:testproj]
basepython = python3
deps =
{[base]deps}
Try renaming your celery.py
file to something else. It might be masking the celery
module installed via requirements (so the from celery import Celery
line could be importing from the module itself).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.