jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 261 forks source link

pychecker does not seem to work #292

Closed twiecki closed 10 years ago

twiecki commented 10 years ago

Every python file I open the first line results in: NOT PROCESSED UNABLE TO IMPORT

This is my config:

Virtualenv........: None
RPC Python........: 2.7.6 (/usr/bin/python)
Interactive Python: python (/usr/bin/python)
Emacs.............: 24.3.1
Elpy..............: 1.5.0
Jedi..............: 0.8.0-final0
Rope..............: 0.9.4
Syntax checker....: pychecker.sh (/usr/bin/pychecker.sh)
jorgenschaefer commented 10 years ago

What does pychecker.sh look like?

twiecki commented 10 years ago
>>cat /usr/bin/pychecker.sh
#!/bin/sh

# We need to execute checker.py rather than simply importing it.  However,
# since pychecker is not a private package, we don't know exactly where it will
# be located.  So, we run a little Python script first to find the correct
# location, and then execute it from there.
#
# Expect CHECKER_PATH to be something like:
#
#    /usr/share/pyshared/pychecker/checker.py
#
# Its actual location will depend on how dh_python2 is implemented.
#
# This script also supports the use of $PYTHONVER as a way to select which
# version of Python will be used to execute pychecker. This will only work for
# versions of Python supported by dh_python2, but it's better than nothing.

PYTHON="/usr/bin/python${PYTHONVER}"
CHECKER_PATH=`${PYTHON} -c "from imp import find_module; print find_module('pychecker/checker')[1]"`

if [ ! -n "${CHECKER_PATH}" ]; then
   echo "Unable to find checker.py on Python's module path."
   exit 1 
fi

if [ ! -f "${CHECKER_PATH}" ]; then
   echo "Found checker.py as [${CHECKER_PATH}], but it does not seem to exist."
   exit 1 
fi

exec "${PYTHON}" "${CHECKER_PATH}" "$@"
jorgenschaefer commented 10 years ago

I'm confused as to where the error you reported is generated. As far as I understand, you open a Python file, and then the string NOT PROCESSED UNABLE TO IMPORT is displayed. Where is that displayed?

If you run M-: (compile (format "pychecker.sh %s" buffer-file-name)), does that produce any output?

twiecki commented 10 years ago

Thanks, that's a bit more informative:

pychecker.sh /home/wiecki/working/projects/hddm/hddm/models/hddm_info.py
Processing module hddm_info (/home/wiecki/working/projects/hddm/hddm/models/hddm_info.py)...
  ImportError: No module named pymc

Warnings...

/home/wiecki/working/projects/hddm/hddm/models/hddm_info.py:1: NOT PROCESSED UNABLE TO IMPORT

Compilation exited abnormally with code 1 at Mon Aug  4 10:22:36

pymc is only installed in the virtualenv. I did activate that though with pyvenv-workon but maybe it's not applied?

jorgenschaefer commented 10 years ago

Your configuration output says Virtualenv........: None so there is no current virtualenv. How did you activate it?

twiecki commented 10 years ago

Right, I retried it after activating the venv as I thought this was the cause but there was no difference:

Virtualenv........: hddm (/home/wiecki/envs/hddm)
RPC Python........: 2.7.5 (/home/wiecki/envs/hddm/bin/python)
Interactive Python: python (/home/wiecki/envs/hddm/bin/python)
Emacs.............: 24.3.1
Elpy..............: 1.5.0
Jedi..............: Not found
Rope..............: 0.9.4
Syntax checker....: pychecker.sh (/usr/bin/pychecker.sh)
jorgenschaefer commented 10 years ago

Ah. The pychecker.sh script uses a hardcoded Python interpreter:

PYTHON="/usr/bin/python${PYTHONVER}"

That is, it does not respect any currently active virtualenv. Setting that variable to "python" (without a full path) should work, though.

twiecki commented 10 years ago

Yep, that does the trick. Thanks!