debugger fails Error loading PATHS_FROM_ECLIPSE_TO_PYTHON from environment variable
hi,
this is a new PyCharm CE on mac os with 2 projects
1. dummy project, to make sure something works
2. pandas
On both projects i setup a run config for pytest. On (1) both run and debug work fine. On (2), run works fine and tests pass, but when i try to use the same config with the debugger, i can a failure at a very early stage for what looks like a bogus reason. By bogus i mean nothing wrong with the code im trying to debug: it gets [far] past this step when running the same configuration.
Interestingly, there is an error reported just before the debugger connects: "Error loading PATHS_FROM_ECLIPSE_TO_PYTHON from environment variable"
Heres the debugger console contents.
I'd really appreciate any help! I use Pycharm pro at work and have never had any issues like this with it
Testing started at 17:51 ...
/Users/robertbuckley/anaconda3/envs/pandas-dev/bin/python "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 58662 --file "/Applications/PyCharm CE.app/Contents/helpers/pycharm/_jb_pytest_runner.py" --path /Users/robertbuckley/python-scripts/pandas-rb/pandas/tests/io/test_excel.py -- -k multiindex
Error loading PATHS_FROM_ECLIPSE_TO_PYTHON from environment variable.
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd_file_utils.py", line 71, in <module>
PATHS_FROM_ECLIPSE_TO_PYTHON = json.loads(os.environ.get('PATHS_FROM_ECLIPSE_TO_PYTHON', '[]'))
AttributeError: module 'json' has no attribute 'loads'
pydev debugger: process 8976 is connecting
Connected to pydev debugger (build 182.3911.33)
Launching pytest with arguments -k multiindex /Users/robertbuckley/python-scripts/pandas-rb/pandas/tests/io/test_excel.py in /Users/robertbuckley/python-scripts/pandas-rb/pandas/tests/io
Traceback (most recent call last):
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 372, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('/Users/robertbuckley/python-scripts/pandas-rb/pandas/tests/io/test_excel.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 372, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('/Users/robertbuckley/python-scripts/pandas-rb/pandas/tests/io')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 403, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/robertbuckley/python-scripts/pandas-rb/pandas/conftest.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 409, in _importconftest
mod = conftestpath.pyimport()
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/py/_path/local.py", line 668, in pyimport
__import__(modname)
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby import Grouper
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.groupby import GroupBy # flake8: noqa
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/core/groupby/groupby.py", line 40, in <module>
from pandas.core.frame import DataFrame
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/core/frame.py", line 74, in <module>
from pandas.core.series import Series
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/core/series.py", line 86, in <module>
import pandas.plotting._core as gfx
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/plotting/__init__.py", line 11, in <module>
from pandas.plotting._core import boxplot
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/plotting/_core.py", line 44, in <module>
from pandas.plotting import _converter
File "/Users/robertbuckley/python-scripts/pandas-rb/pandas/plotting/_converter.py", line 8, in <module>
import matplotlib.units as units
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/matplotlib/__init__.py", line 140, in <module>
__version__ = str(get_versions()['version'])
File "/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/matplotlib/_version.py", line 21, in get_versions
return json.loads(version_json)
AttributeError: module 'json' has no attribute 'loads'
ERROR: could not load /Users/robertbuckley/python-scripts/pandas-rb/pandas/conftest.py
Process finished with exit code 0
Empty test suite.
Please sign in to leave a comment.
i found the issue. I left the working directory in the run/test config empty. According to https://www.jetbrains.com/help/pycharm/2018.2/run-debug-configuration-py-test.html, "When this field is left blank, the
bindirectory of the PyCharm installation will be used"Run worked fine
However, it seems that in debug mode, it was setting the working directory to the same path as the test script specified in the Target field of the run/config dialog. That caused "import json" to pick up a module in the project test hierarchy, rather than the standard library called json from site-packages
This broke everything that tried to use the standard library json, including /Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd_file_utils.py
What i dont understand is why this run/test config worked fine for running, but broke only for the debugger.
Its not blocking me anymore, but maybe this is something to be addressed?