Created attachment 402120 [details] files matching winreg substring I use pychecker to check my python code. Recently, it started to print ImportError during importing itself or its required modules this: $ pychecker mytool.py Processing module mytool (mytool.py)... warning: couldn't find real module for class <class 'cElementTree.ParseError'> (module name: cElementTree) warning: couldn't find real module for class <class 'fftpack.error'> (module name: fftpack) warning: couldn't find real module for class <class 'lapack_lite.LapackError'> (module name: lapack_lite) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) warning: couldn't find real module for class <type 'cntr.Cntr'> (module name: cntr) ImportError: No module named _winreg The warnings have always been there as far as I remember. Here is strace output of the above command with last files accessed befoore winreg appears. [pid 25950] open("/usr/lib64/python2.7/site-packages/dateutil/tzwin.py", [pid 25950] read(12, "-packages/dateutil/tzwin.pyt\10\0\0\0"..., 4096) = 2646 [pid 25950] stat("_winreg", 0x7fff048f75c0) = -1 ENOENT (No such file or directory) [pid 25950] open("/usr/lib64/python2.7/cgi.py", O_RDONLY) = 5 [pid 25950] stat("_winreg", 0x7fff048f7e60) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winregmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.py", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.pyc", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] stat("_winreg", 0x7fff048f7e60) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winregmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.py", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.pyc", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("/usr/lib64/python2.7/lib-tk/ttk.py", O_RDONLY) = 3 [pid 25950] stat("_winreg", 0x7fff048f8dc0) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winregmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.py", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.pyc", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] stat("_winreg", 0x7fff048f8dc0) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winregmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.py", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] open("_winreg.pyc", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 25950] write(2, " ImportError: ", 15 ImportError: ) = 15 [pid 25950] write(2, "No module named _winreg\n", 24No module named _winreg ) = 24 # equery belongs /usr/lib64/python2.7/site-packages/dateutil/tzwin.py * Searching for /usr/lib64/python2.7/site-packages/dateutil/tzwin.py ... dev-python/python-dateutil-2.4.2 (/usr/lib64/python2.7/site-packages/dateutil/tzwin.py) # equery belongs /usr/lib64/python2.7/lib-tk/ttk.py * Searching for /usr/lib64/python2.7/lib-tk/ttk.py ... dev-lang/python-2.7.9-r2 (/usr/lib64/python2.7/lib-tk/ttk.py) # equery belongs /usr/lib64/python2.7/cgi.py * Searching for /usr/lib64/python2.7/cgi.py ... dev-lang/python-2.7.9-r2 (/usr/lib64/python2.7/cgi.py) # Clues? Is this a python issue or from dev-python/python-dateutil or else? Will attach output from: find /usr/lib* -type f | while read f; do grep -H _winreg $f; done
What's in mtool.py?
Here are the imports: import faulthandler import gc import sys, os, datetime import glob import re import tempfile from subprocess import Popen, PIPE, call from StringIO import StringIO from optparse import OptionParser from itertools import izip, imap, ifilter, chain import difflib import colorsys from random import uniform from operator import itemgetter from textwrap import wrap from math import ceil import matplotlib import pylab import numpy as np from Bio import SeqIO from Bio.Seq import Seq, reverse_complement from Bio.Alphabet import generic_dna from decimal import Decimal import copy import gdbm import bsddb3 import bsddb from Bio import SearchIO from Bio import __version__ as _biopython_version from distutils.version import StrictVersion from Bio.SeqIO.FastaIO import FastaWriter from Bio import SearchIO
OK, "import pylab" is the source of the error. # emerge -pv matplotlib These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] dev-python/matplotlib-1.4.3::gentoo USE="cairo examples fltk gtk tk wxwidgets -doc -excel -gtk3 -latex -pyside -qt4 -qt5 {-test}" PYTHON_TARGETS="python2_7 -python3_3 -python3_4" 0 KiB # I use python 2.7.
$ pychecker test.py Processing module test (test.py)... warning: couldn't find real module for class <class 'fftpack.error'> (module name: fftpack) warning: couldn't find real module for class <class 'lapack_lite.LapackError'> (module name: lapack_lite) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) ImportError: No module named _winreg warning: couldn't find real module for class <type 'cntr.Cntr'> (module name: cntr) Warnings... test.py:3: Imported module (pylab) not used $ cat test.py #! /usr/bin/python import pylab $
I see the same, though I don't know what it is.
+*six-1.9.0-r1 (06 May 2015) + + 06 May 2015; Justin Lecher <jlec@gentoo.org> +files/six-1.9.0-winreg.patch, + +six-1.9.0-r1.ebuild, metadata.xml, six-9999.ebuild: + Backport fix for windows only modules, bug #547928 + So this one was a six problem. I still see additional import problems. How about you?
I also asked at [Matplotlib-users] ImportError: No module named _winreg and the only hint I received is from Thomas Caswell: <quote> winreg looks like it is for programmatic access to the windows registry which mpl uses to find fonts in windows (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/font_manager.py#L173). I suspect this is a problem with pychecker being too enthusiastic about checking imports. </quote> I think it is either due to recent six package update or matplotlib. I cannot test now on my live system.
(In reply to Martin Mokrejš from comment #7) > I think it is either due to recent six package update or matplotlib. I > cannot test now on my live system. It was in six which I backported the fix for in six-1.9.0-r1.