PROBLEM

Python Exception error "bad magic number in 'requests.packages': b'\x03\xf3"

Last Published: April 16, 2024

Description

In some scenarios, such as calling a Data Interoperability Spatial ETL Tool from a Python script, the following error is returned:

Error: 
bad magic number in 'requests.packages': b'\x03\xf3

The "magic number" comes from UNIX-type systems where the first few bytes of a file held a marker indicating the file type. Python puts a similar marker into its pyc files when it creates them. The Python interpreter ensures that this number is correct when loading the file.

Note: 
ArcMap is in Mature support and will be retired March 1, 2026. There are no plans for future releases of ArcMap, and it is recommended that you migrate to ArcGIS Pro. See Migrate from ArcMap to ArcGIS Pro for more information.

Cause

Anything that damages this magic number will cause the error. This includes editing the .pyc file or trying to run a .pyc file from a different version of Python (usually later) than your interpreter.

Solution or Workaround

  1. If the issue is with your .pyc files, delete them and let the interpreter re-compile the .py files. On UNIX-type systems, that could be something as simple as:
rm *.pyc

or:

find . -name '*.pyc' -delet
  1. Uninstall the Data Interoperability extension.
  2. Reinstall the correct version of Python.
  3. Reinstall Data Interoperability.

Article ID: 000025627

Software:
  • ArcMap 10 8

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options