-
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
bad magic number in 'application': b'\x03\xf3\r\n': ImportError #854
Comments
I've fixed this by completely deleting the repository and then re-cloning. I'm assuming that zappa uses some .pyc file from the project itself, not sure if it is worth adding some recompilation functionality, the 2.7 -> 3.6 use case probably doesn't occur frequently enough to warrant it. Hopefully this helps someone else in the same boat though :) |
I was able to fix this too, by doing |
thanks, @jakul this really helped me out! |
This can happen if you move a directory into another directory without deleting the .pyc cache. |
|
@amiashraf it was my solution too! i has same error when importing celery library on Django 2.0.2 |
XXX EDIT FROM MAINTAINTER: THIS IS BAD ADVICE DONT DO THIS XXX Or |
uh, Running |
@nosarthur your comment made me lose work.. |
the issue is caused by differences conflicts in python versions within the cache. The cache is stored under file name as ' pycach' try finding these file and deleting them then trying running the project with the correct version of python again. |
thanks!!!!!!!, @jakul you save my life!!!! |
thank you, its solve my question |
Thanks @jakul . It works !!! ;) |
Thanks a lot @jakul !! |
Thanks @jakul and @texonidas , you guys a re lifesavers! |
+1 Thank you! Worked for me! |
Which directory should I run |
I run into this problem on windows machine while I was trying to create a new project in PyCharm. |
Move to your home directory and run in your terminal this |
I have just made the switch from 2.7 to 3.6, however upon undeploying and redeploying my application, I received the above error, with the stack trace below.
Context
bad magic number in 'application': b'\x03\xf3\r\n': ImportError Traceback (most recent call last): File "/var/task/handler.py", line 514, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 259, in lambda_handler handler = cls() File "/var/task/handler.py", line 148, in __init__ self.app_module = importlib.import_module(self.settings.APP_MODULE) File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 888, in get_code File "<frozen importlib._bootstrap_external>", line 455, in _validate_bytecode_header ImportError: bad magic number in 'application': b'\x03\xf3\r\n'
From my research, this error occurs when old .pyc files are kept between version changes of Python. Given that I fully undeployed then redeployed this project, I'm unsure how else I can go about clearing them.
Expected Behavior
Normal deployment
Actual Behavior
Hella crashes
Possible Fix
As mentioned above, there are a few suggestions online that this is caused by Python 2.x .pyc files making their way into the new Python 3.x project.
Steps to Reproduce
Unfortunately this is an error I am unable to reproduce from a fresh install, as it is a long running closed-source project.
Your Environment
zappa_settings.py
:"develop": { "app_function": "application.app", "delete_s3_zip": false, "domain": "api.develop.website.com.au", "http_methods": ["GET", "OPTIONS", "POST"], "keep_warm": false, "lets_encrypt_expression": "rate(15 days)", "lets_encrypt_key": "s3://website-config/develop.key", "method_header_types": [ "Content-Type", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Access-Control-Allow-Methods", "Location", "Status", "X-Frame-Options", "Set-Cookie" ], "remote_env": "s3://website-config/dev-config.json", "s3_bucket": "website-api-develop", "timeout_seconds": 70, "vpc_config": { "SubnetIds": ["secret"], "SecurityGroupIds": ["also secret"] } }
The text was updated successfully, but these errors were encountered: