-
Notifications
You must be signed in to change notification settings - Fork 84
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
ImportError: cannot import name 'abc' #82
Comments
This is frustrating as there is no more tags(versions) on github to easily track the problem. I'm also trying to revert to 0.5.2, and I get
which is related to a bad use of pip (pypa/pip#5243) If by any chance you happen to have this error with pymongo; try this https://stackoverflow.com/a/46166075 |
uninstall bson, then install pymongo will solve this.
I think another bson package is what you are looking for. https://github.com/mongodb/mongo-python-driver |
uninstall bson and pymongo and reinstall pymongo using conda:
|
I had to add Update: still not working properly. My app runs on Heroku and only there I see this issue, can't reproduce on my local machine or on Travis-CI |
It seems that this issue is raising when installed py-bson and pymongo both. If anyone encounter this issue whithout pymongo, please comment it with how to reproduce(environments and more). Thank you. |
I'm not using them both, I tried to install The problem is that I'm not getting this error on my local machine (Mac) or in the CI (Travis), only on heroku. Update: I have posted a question on StackOverFlow with more info |
There seems to remain a lack of clarity, so, from the most useful SO post I found on this issue from @bauman.space:
|
I posted that question, you can see it in the previous comment :)
|
Haha, yes, see that now. Well, thanks for posting. I believe your pymongo file may remain corrupted/ partially overwritten by the earlier bson install. I had this same issue, and per the thread, attempted a pymongo reinstall to resolve. My virtual env, however, seems to have a bit of an issue with updating, so reinstalling pymongo did not resolve the issue. I deleted the generated .venv repo, and ran a blanket install. Now the issues are resolved for me. So for me, |
I'm running on Heroku so I can't control how the environment is been set up. I run |
Thanks , solved the issue |
I have Python 3.7.0 running in a virtual environment on MacBook Pro Mojave 10.14.3 |
It works for me. |
Confirmed. If you install bson first and then pymongo, it works. |
This dependency is conflicting with pymongo and resulting in the following exception: ---- ImportError while importing test module '/var/lib/jenkins/workspace/cmk_master/unit_tests/check_mk/tests/unit/agents/plugins/test_mk_mongodb.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/_pytest/python.py:507: in _importtestmodule mod = self.fspath.pyimport(ensuresyspath=importmode) ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/py/_path/local.py:701: in pyimport __import__(modname) ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py:304: in load_module exec(co, mod.__dict__) unit/agents/plugins/test_mk_mongodb.py:5: in <module> from bson.json_util import loads ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/bson/json_util.py:116: in <module> from pymongo.errors import ConfigurationError ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/pymongo/__init__.py:77: in <module> from pymongo.collection import ReturnDocument ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/pymongo/collection.py:20: in <module> from bson.code import Code ../virtual-envs/2.7/.venv/local/lib/python2.7/site-packages/bson/code.py:18: in <module> from bson.py3compat import abc, string_type, PY3, text_type E ImportError: cannot import name abc --- According to py-bson/bson#82 both packages are conflicting and bson needs to be cleaned up. Change-Id: I82383157176ba3230408285c142d7fc92cedccae
Coming across the same thing today. Any suggestions on how to detect the root cause ? |
@dparkar the following (based on what worked for others in this thread) worked for me: pip uninstall -y bson pymongo \
&& pip install bson==0.5.7 \
&& pip install pymongo==3.7.2 |
@Affan-Ali this guy is great
This solve it, is better to install with conda than pip if u r using anaconda |
TLDR; remove The problem appears to be that This is the problem with pip, where 2 packages can deliver the same module name. The issue can be caused by the following 2 scenarios:
Steps to reproduce require the following 3 files:
Then you simply run Weirdly, if you have a transitive dependency to In summary: this repository should only be used, if you ONLY need bson functionality and don't want to use MongoDB. Otherwise omit it entirely as you can |
I have same problem I resolved with uninstall with pip and install with pip3
|
guys, I uploaded pybson to pypi for looking on demands. (same package with bson.) |
This worked for me: pip uninstall bson |
Worth noting that I experienced the same issue today running the latest versions of each package. Solved by removing bson |
from bson.py3compat import abc, string_type, PY3, text_type
ImportError: cannot import name 'abc'
The text was updated successfully, but these errors were encountered: