-
Notifications
You must be signed in to change notification settings - Fork 275
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
bad magic number in 'six' #359
Comments
|
@chrisdamato I ran into this today. The culprit ended up being a Once I removed that file, the error went away. |
|
When you run e.g. We (Fedora) would like to start using a flag in shebang lines of Python scripts installed in |
See https://bugzilla.redhat.com/show_bug.cgi?id=2057340 and benjaminp/six#359 dnf should never import Python modules from /usr/bin but users can have files in there that look like Python modules and Python will try to import them and fail. Consider a tool that is *not* written in Python and is called "copy.pyc". Naturally, it resides in /usr/bin/copy.pyc and dnf fails: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: bad magic number in 'copy': b'...' Similarly, a tool actually written in Python, called "copy.py" might have as well own /usr/bin/copy.py and dnf fails as well: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py) Either problem can happen for a variety of names. We better not let that happen. A more general solution that would prevent Python doing this entirely does not exists yet, see https://discuss.python.org/t/4235 Hence, proposing this to dnf, which is a critical piece of the system.
|
I've opened rpm-software-management/dnf#1815 for dnf specifically, but this can happen to any Python script residing in a directory like |
See https://bugzilla.redhat.com/show_bug.cgi?id=2057340 and benjaminp/six#359 dnf should never import Python modules from /usr/bin but users can have files in there that look like Python modules and Python will try to import them and fail. Consider a tool that is *not* written in Python and is called "copy.pyc". Naturally, it resides in /usr/bin/copy.pyc and dnf fails: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: bad magic number in 'copy': b'...' Similarly, a tool actually written in Python, called "copy.py" might as well own /usr/bin/copy.py and dnf fails as well: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py) Either problem can happen for a variety of names. We better not let that happen. A more general solution that would prevent Python doing this entirely does not exists yet, see https://discuss.python.org/t/4235 Hence, proposing this to dnf, which is a critical piece of the system.
|
I've also opened https://discuss.python.org/t/should-console-scripts-entry-points-exclude-the-scripts-directory-from-sys-path/13896 for console_scripts entry points (which dnf is not) |
See https://bugzilla.redhat.com/show_bug.cgi?id=2057340 and benjaminp/six#359 dnf should never import Python modules from /usr/bin but users can have files in there that look like Python modules and Python will try to import them and fail. Consider a tool that is *not* written in Python and is called "copy.pyc". Naturally, it resides in /usr/bin/copy.pyc and dnf fails: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: bad magic number in 'copy': b'...' Similarly, a tool actually written in Python, called "copy.py" might as well own /usr/bin/copy.py and dnf fails as well: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py) Either problem can happen for a variety of names. We better not let that happen. A more general solution that would prevent Python doing this entirely does not exists yet, see https://discuss.python.org/t/4235 Hence, proposing this to dnf, which is a critical piece of the system.
See https://bugzilla.redhat.com/show_bug.cgi?id=2057340 and benjaminp/six#359 dnf should never import Python modules from /usr/bin but users can have files in there that look like Python modules and Python will try to import them and fail. Consider a tool that is *not* written in Python and is called "copy.pyc". Naturally, it resides in /usr/bin/copy.pyc and dnf fails: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: bad magic number in 'copy': b'...' Similarly, a tool actually written in Python, called "copy.py" might as well own /usr/bin/copy.py and dnf fails as well: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py) Either problem can happen for a variety of names. We better not let that happen. A more general solution that would prevent Python doing this entirely does not exists yet, see https://discuss.python.org/t/4235 Hence, proposing this to dnf, which is a critical piece of the system.
…ing garbage See https://bugzilla.redhat.com/show_bug.cgi?id=2057340 and benjaminp/six#359 dnf should never import Python modules from /usr/bin but users can have files in there that look like Python modules and Python will try to import them and fail. Consider a tool that is *not* written in Python and is called "copy.pyc". Naturally, it resides in /usr/bin/copy.pyc and dnf fails: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: bad magic number in 'copy': b'...' Similarly, a tool actually written in Python, called "copy.py" might as well own /usr/bin/copy.py and dnf fails as well: Traceback (most recent call last): File "/usr/bin/dnf", line 57, in <module> from dnf.cli import main File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module> import dnf.base File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module> from copy import deepcopy ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py) Either problem can happen for a variety of names. We better not let that happen. A more general solution that would prevent Python doing this entirely does not exists yet, see https://discuss.python.org/t/4235 Hence, proposing this to dnf, which is a critical piece of the system.
Fedora 33. Any dnf or yum command produces the same error message before the normal output of the command:
Failed loading plugin "changelog": bad magic number in 'six': b'\x03\xf3\r\n'For example:
I tried updating the system, reinstalling six using pip and dnf, no change.
If I start python3 and import six, there is no error message. If I disable the changelog plugin to dnf (a builtin apparently) the message does not appear.
Hope I'm doing this right. Thanks for any help you are able to provide.
The text was updated successfully, but these errors were encountered: