-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
"import configparser" broke load ConfigParser #1871
Comments
If your program already imports PyQt4, why do you need |
QThread (in conjunction with the subprocess) did not work in my program without calling of collect_submodules('PyQt4'). But it was a few months ago. I will check if they have started to work in the current state of the branch. |
On this commit the bug is appeared (found with git bisect):
|
Some debugging ideas:
|
Ok, I tried minimal example. Error "No module named ConfigParser" raises in any order of imports. The source code for the test and logs of pyinstaller work and results of the created EXE-file: |
And even
does not work when add collect_submodules('PyQt4') to spec-file |
I think the
and that produces the same failure when packaged just with
I do also see this during the build:
This might be a Windows issue... I was unable to reproduce the minimal example on OS X. |
So you have Please try to find out, why this is happening. I assume that for some reason
|
For point "Please try in a virtaul env where only configparser is installed." I looked at the configparser. It is a simlpe folder with init.py file: from __future__ import absolute_import
import sys
if sys.version_info[0] < 3:
from ConfigParser import *
try:
from ConfigParser import (_Chainmap, Error, InterpolationMissingOptionError)
except ImportError:
pass
else:
raise ImportError('This package should not be accessible on Python 3. '
'Either you are trying to run from the python-future src folder '
'or your installation of python-future is corrupted.') And any call of configparser in frozen code does not work (raise exception about no module ConfigParser). import configparser
print "success"
import configparser
import ConfigParser
print "success"
import ConfigParser
import configparser
print "success" Simple import ConfigParser is work success So if you import 'ConfigParser' and 'configparser', only 'configparser' will be imported. But 'configparser' use 'ConfigParser', so exception will be raised. |
I did some more investigation, and this is likely an environmental problem. It also appears to be the same issue reported in PythonCharmers/python-future#118 I had, on my machine, a folder named configparser that is how @ombschervister described it. I separately had, in site-packages, a configparser.py module. I think that's the root of the issue. I was able to get this to work (in that the minimal example built and ran) by just removing the configparser folder. That folder is provided by python-future (see above issue). I'm not entirely sure what the best way for PyInstaller to detect, workaround or fix this issue. You'd need some sort of conditional hook where "if python-future is installed and configparser is imported, also include ConfigParser and maybe fix some case issues if you're on Windows." It's possible for authors to work around this by installing the 3.5.0b2 version of configparser and changing the import to be |
Maybe it is not Windows problem only, but the problem for equal lowercased names of folders and files for any operation system? from lib import test as file_test
from LIB import test as folder_test
file_test()
folder_test()
print "success" lib.py: def test():
print "file" folder LIB with init.py: def test():
print "folder" Maybe so Pyinstaller need to add '' to end of package names in the unique-filename set and does not hook configparser? |
I had a similar case so I tried to use the pre_safe_import_module/hook-configparser.py: from PyInstaller.compat import is_py2
if is_py2:
def pre_safe_import_module(psim_api):
psim_api.add_alias_module('ConfigParser', 'configparser') The duplicate upper/lowercases warning still remain though. |
I did not see those changes and you are right, this correct this issue altogether. |
Duplicate of #1935 |
I’ve found an apparent bug.
Downloaded winpython 2.7.10.104, installed with pip the following libraries:
Then if I try to use collect_submodules(‘PyQt4’) in the spec-file,
ConfigParser import is not working
Error Messages:
In the master branch:
In the develop branch:
Here the code:
spec-file:
python-file
The text was updated successfully, but these errors were encountered: