Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'pandas' has no attribute 'plotting' with tox #17520

Closed
cachitas opened this issue Sep 13, 2017 · 7 comments
Closed

AttributeError: module 'pandas' has no attribute 'plotting' with tox #17520

cachitas opened this issue Sep 13, 2017 · 7 comments

Comments

@cachitas
Copy link

pandas 0.20.3 fails to import on every test when running tox.

  • tox packages installed, besides my package:

cycler==0.10.0, matplotlib==2.0.2, numexpr==2.6.2, numpy==1.13.1, pandas==0.20.3, py==1.4.34, pyparsing==2.2.0, pytest==3.2.2, pytest-travis-fold==1.2.0, python-dateutil==2.6.1, pytz==2017.2, scipy==0.19.1, six==1.10.0, tables==3.4.2

  • platform linux -- Python 3.5.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0

  • all tests fail with the following error:

myfile.py:16: in <module>
    import pandas as pd
.tox/3.5-nocov/lib/python3.5/site-packages/pandas/__init__.py:51: in <module>
    plot_params = pandas.plotting._style._Options(deprecated=True)
E   AttributeError: module 'pandas' has no attribute 'plotting'

Testing the same import in a virtualenv without tox works correctly.

Looks like it is a problem with pandas, but could also be something regarding tox (or even pytest). Hopefully, someone more experienced with tox can guide me here.

Output of pd.show_versions()

Taken from the virtualenv I created to test outside tox.

INSTALLED VERSIONS

commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-93-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: pt_PT.UTF-8

pandas: 0.20.3
pytest: 3.2.2
pip: 9.0.1
setuptools: 28.8.0
Cython: None
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: None
sphinx: 1.6.3
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
None

@jreback
Copy link
Contributor

jreback commented Sep 14, 2017

you cannot run tox with a production installation, you need to clone the project and build, see the contributing guide

@jreback jreback closed this as completed Sep 14, 2017
@jreback jreback added Testing pandas testing functions or related to the test suite Usage Question labels Sep 14, 2017
@jreback jreback added this to the No action milestone Sep 14, 2017
@cachitas
Copy link
Author

Sorry I can't see how that helps.

I am not testing pandas itself. I am testing my own library with tox, where one of the dependencies is pandas. Previously, for pandas==0.19.2 my tests would pass, but now with the latest pandas version they all fail when importing pandas, as explained above.

@TomAugspurger
Copy link
Contributor

Can you post a minimal tox.ini that reproduces this?

@cachitas
Copy link
Author

I am testing in Python 3.5 and 3.6, all outputting the same errors. Here you have an example just with one case.

[tox]
envlist =
    clean,
    3.5-nocov

; required by the docker image used
skipsdist = {env:TOXBUILD:false}

[testenv]
basepython =
    {clean,check,report,codecov,docs,spell}: python3.5
usedevelop = true
setenv =
    PYTHONPATH={toxinidir}/tests
    PYTHONUNBUFFERED=yes
passenv =
    *
deps =
    pytest
    pytest-travis-fold
commands =
    {posargs:py.test -vv --ignore=mypackage}

[testenv:clean]
commands = coverage erase
skip_install = true
usedevelop = false
deps = coverage

[testenv:3.5-nocov]
basepython = {env:TOXPYTHON:python3.5}

@jorisvandenbossche jorisvandenbossche removed Testing pandas testing functions or related to the test suite Usage Question labels Sep 14, 2017
@jorisvandenbossche jorisvandenbossche removed this from the No action milestone Sep 14, 2017
@TomAugspurger
Copy link
Contributor

TomAugspurger commented Sep 14, 2017

@cachitas that's not quite minimal. I meant something like

[tox]
envlist = py36
skipsdist = True

[testenv]
deps=
    pytest
    pandas
commands=pytest

Along with

# file: test_foo.py
import pandas

def test_bar():
    pass

Here's the output of tox

GLOB sdist-make: /private/tmp/setup.py/setup.py
py36 inst-nodeps: /private/tmp/setup.py/.tox/dist/mypackage-5.2.0.zip
py36 installed: mypackage==5.2.0,numpy==1.13.1,pandas==0.20.3,py==1.4.34,pytest==3.2.2,python-dateutil==2.6.1,pytz==2017.2,six==1.10.0
py36 runtests: PYTHONHASHSEED='3595071649'
py36 runtests: commands[0] | pytest
================================================ test session starts =================================================
platform darwin -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0
rootdir: /private/tmp/setup.py, inifile:
collected 1 item

test_foo.py .

============================================== 1 passed in 0.30 seconds ==============================================
______________________________________________________ summary _______________________________________________________
  py36: commands succeeded
  congratulations :)

@cachitas
Copy link
Author

cachitas commented Sep 14, 2017

Apologies for not being so concise, but I wanted to illustrate my tox.ini without omitting the potential source of the problem.

I already tested your example in my machine and it is working.

So my next step was to build up step by step from that until I get the error reported, and it looks it comes from pytest.

I have the following configuration in setup.cfg:

[tool:pytest]
norecursedirs =
	.git
	.tox
	.env
	dist
	build
python_files =
	test_*.py
	*_test.py
	tests.py
addopts =
	-rxEfsw
	--strict
	--ignore=docs/conf.py
	--ignore=setup.py
	--ignore=.eggs
	--doctest-modules
	--doctest-glob=\*.rst
	--tb=short

After a quick test I found that the --strict option is the root of all evil. This led me to #16852 and #16680. Apparently you have already tackled this issue. I just complicated it a lot more because I could not identify the problem immediately. Hopefully, this should be fixed in the next bugfix release.

@TomAugspurger
Copy link
Contributor

Ahh, yeah that issue has been an unanticipated headache of switching to pytest.

I think there was a workaround where you add the change in https://github.com/pandas-dev/pandas/pull/16797/files to your conftest.py and pytest won't complain? Otherwise, the next release is in about 2 weeks, and things should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants