25
Finally, I found the answer, The project has .pyc files, which holds the previous version information and time date, so this error. After deleting those files I got the output.
- [Django]-How to read the database table name of a Model instance?
- [Django]-What does 'many = True' do in Django Rest FrameWork?
- [Django]-Django or Django Rest Framework
24
You can delete all the .pyc files in your folder to resolve it.
find . -name \*.pyc -delete
- [Django]-Django – filtering on foreign key properties
- [Django]-How to check if django template variable is defined?
- [Django]-Django: Open uploaded file while still in memory; In the Form Clean method?
16
Included in your checkout are .pyc
files. These are byte cache files, storing cached bytecode so Python can avoid having to parse and compile the source files. Unless you plan to distribute a project without source files, these should not be included.
Just delete all .pyc
files located in the same directory as .py
files.
The “magic number” in the error message is a version number for the bytecode stored, and specific Python versions only work with specific bytecode magic numbers; the number in your error is equal to 62211 in decimal (when interpreted as a little-endian number), which shows the .pyc
files were created with a Python 2.7 interpreter.
Python 3.2 switched to storing .pyc
files in separate __pycache__
directories and including the Python version in the filename. However, any .pyc
files still located next to the .py
files are supported still to allow for bytecode-only releases. It’s safe to delete such files because if you were to use a Python 2.7 interpreter in future, then the files will be re-created.
- [Django]-Django – Simple custom template tag example
- [Django]-Django Forms: pass parameter to form
- [Django]-How do I do an OR filter in a Django query?
8
Delete the .pyc files created in your directory .’
ex : i have gitlab.py and gitlab.pyc
later i renamed it into gitlab-api.py
But while running python file , it is using gitlab.pyc so
Traceback (most recent call last):
File "gitlab-api.py", line 1, in
import gitlab
ImportError: bad magic number in ‘gitlab’: b’\x03\xf3\r\n’
it worked correctly when i deleted the gitlab.pyc
- [Django]-Import data from excel spreadsheet to django model
- [Django]-Django render_to_string missing information
- [Django]-How to squash recent Django migrations?
4
you will need to delete any pyc. pyc is the cache of your app. delete all files that end with .pyc and rerun your app.
- [Django]-How to create a user in Django?
- [Django]-DatabaseError: value too long for type character varying(100)
- [Django]-Why does Django make migrations for help_text and verbose_name changes?
2
If your OS is Windows you have to delete Python’s older versions, then you are ready to use pip
again. This is the best method, without errors.
- [Django]-Is it secure to store passwords as environment variables (rather than as plain text) in config files?
- [Django]-"No 'Access-Control-Allow-Origin' header is present on the requested resource" in django
- [Django]-How to reset db in Django? I get a command 'reset' not found error
- [Django]-Django: Multiple forms possible when using FormView?
- [Django]-Django: Why do some model fields clash with each other?
- [Django]-Sorting related items in a Django template