-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 pkg_resources.py31compat causes no module error #1167
Comments
Actually, I see now that this also happens in easy_install.py.
It would be easy enough to fix, but, is there a clear reason why this is causing errors? These individual files are not recognized as modules on their own, and are included by their containing submodules. |
Yes.
Really? You get "no module errors" in attempts to import I'm going to have to ask you to do more investigation, as these modules work just fine in CI tests and for most users all day long. My suspicion is that there's something unique to your environment that's corrupting or changing your installation of setuptools after your environment is started up. Maybe you're starting Jupyter, then installing packages or downgrading packages. Such a change might cause parts of setuptools to be imported from one install and others from another install. If you can provide steps to replicate the issue, especially if the steps are minimally producing the error, someone here may be able to help investigate. |
Seeing a similar issue, but when starting up Zope. (I know Zope does a lot of module path scanning and importing which may cause this. However, when I replace the line in Really no idea what's happening here and where the actual problem is. Just thought I'll throw this in to provide a potential pointer into the issue. |
Came upon this thread when following http://webapp.org.ua/build-automation/using-buildout-system-on-windows/ (used latest where I could). Python 2.7 installed via https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi
|
@mtdeguzis I think there's evidence of a corrupted install in your traceback. Notice how So you probably have two installs of setuptools, one as an egg and another 'externally managed' (maybe pip or virtualenv installed). If you're using buildout or any installer than pip, your best bet is to work with that installer project to help ascertain where things went awry. Most likely, you can work around the issue by removing the offending packages (i.e. Based on this new evidence, I don't believe there's a flaw in Setuptools that needs to be corrected, but rather we're seeing evidence of improper installs that's only been exaggerated by the introduction of this (proper) import. Feel free to continue to investigate. If you can find a valid scenario that I can replicate, especially without involving external installers like buildout, I can continue to investigate. If you can replicate the issue with buildout only, I suggest working with that project to isolate the issue. |
That was the case, extra package, thanks |
Me too.
When I upgrade easy_install with easy_install --version
Traceback (most recent call last):
File "/path/to/.pyenv/versions/3.6.2/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==36.7.2', 'console_scripts', 'easy_install')()
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/setuptools-36.7.2-py3.6.egg/setuptools/command/easy_install.py", line 47, in <module>
File "/path/to/.pyenv/versions/3.6.2/lib/python3.6/site-packages/setuptools-36.7.2-py3.6.egg/setuptools/sandbox.py", line 15, in <module>
ModuleNotFoundError: No module named 'pkg_resources.py31compat' |
You've bumped up against limitations in
The recommendation here is to not use |
Hi, ... I know this issue is closed, but here is my case... I have pip 9.0.1 installed, which has a 'vendored in' version of pkg_resources without py31compat package.... Whichever pkg_resources get's loaded first is the winner ;( |
@gweis: Even though pip has a vendored pkg_resources, I wouldn't expect that version of pkg_resources to be loaded as
So in that case, if one were to |
Finally tracked it down. I suspected that pip may be the issue because, that was the only other pkg_resources module I could find in my file system. (also there is no other setupttools version installed anywhere) However, in my case I have a namespace module When my app starts up, something is importing stdlib Essentially, using Lesson to take form this. Don't use (Still not clear why using |
While pip installing jupyter with a version of setuptools cloned just before this post, I came across a no module error coming from setuptools:
ImportError: No module named py31compat
which comes from setuptools/setuptools/sandbox.py, line 15
import pkg_resources.py31compat
However, in
setuptools/pkg_resources/__init__.py
, line 72, py31compat is imported there:from . import py31compat
Therefore, it seems unnecessary to do
import pkg_resources.py31compat
in sandbox.py. It's a python file already included when importing the pkg_resources submodule. One can just do:
import pkg_resources
This fixed the problem for me.
Any reason for using an import statement directly to the python file within the submodule that already includes it in init.py?
I've also had this problem on older python environments while installing other libraries. Not sure what would change in an existing environment to cause this problem.
The text was updated successfully, but these errors were encountered: