[Solved] Symbol not found: __PyCodecInfo_GetIncrementalDecoder

In this article, we will solve Symbol not found: __PyCodecInfo_GetIncrementalDecoder. But before doing that, first, we will try to understand why this error occurs and what it means. Let’s start.

Reason of error in OSX

Usually, these errors occur when bash is unable to locate the python executable files due to incorrect location in the Path variable. These kinds of errors happen when one will update their python version, which leads to changes in python’s Path Variable.

However, the main problem occurs when you try to locate your python, showing the correct path to the python. It may also cause that when you try to execute a file by giving the exact path, it will use a different Python version than it is simply. Let’s take more dive into the problem and see it with the example.

First, Let’s run python with the exact path and see the output:

$ /usr/local/bin/python -c "import sys; print sys.executable; print sys.version_info"

Output:

/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)

Now, let’s try to use virtual environment pythons and see the output.

$ /usr/bin/env python -c "import sys; print sys.executable; print sys.version_info"

Output:

/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)

So far, so good, Now, let’s try to run the same commands without describing the exact path and see the output:

$ python -c "import sys; print sys.executable; print sys.version_info"
/usr/local/bin/python
sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)

Wait!! What !!, There is a version mismatch, But Why?

So, The answer to the question is straightforward.

Bash maintains a cached lookup table in memory. You can examine using  “hash.” The error is that after updating the python, version bash uses the old python version from the cache. At the same time, modules are loaded by the new python version (including the io module), and hence system raises the error.

Python version having this error

This error generally occurs in upgradation from python 2.7.10 to 2.7.11 versions.

Fixing Symbol not found: __PyCodecInfo_GetIncrementalDecoder

Resetting cache lookup memory

Fixing the given error requires defining the appropriate path to bash, which can be achieved by resetting the cached lookup table. You can run the following command to do that.

$ hash -r python

Reinstalling Python [Homebrew]

$ brew unlink python && brew reinstall python

After that, we have to secure path using,

$ export PYTHONPATH=$PYTHONPATH:/usr/local/bin/
$ sudo nano /etc/paths

Anaconda Issue

If you are using the anaconda, you can resolve the issue by simply opening the ~/.bash_profile file and then finding the following line of code in that file and commenting on it,i.e.

export PATH="//anaconda/bin:$PATH

Your problem will be resolved.

FAQs on Symbol not found: __PyCodecInfo_GetIncrementalDecoder

Q1) What is the “symbol not found” error in general?

“Symbol not found” error is raised when the definition of the declared function or variable is not found. When a header file of a shared object is compiled with the program, the linker adds symbols of declared functions and objects to the compiled program. When the OS’s loader loads your program, the symbols are resolved so that their definition will be loaded, and if it is failed to resolve those symbols, it raises the “Symbol not found” error.

Q2) What is the task of GetIncrementalDecoder?

When we save any file in the disk drive of our system, it gets loaded in binary format. To do that, it has to pass through the multi-step encoding process, and similarly, to get that file in human understanding language, it needs to get passed through multi-step decoding processes. In that process returned object of one decoder is required to pass through another decoder called the incremental decoder. GetIncrementalDecoder gives us access to that gradual decoder so that previously returned objects pass through it.

Conclusion

So, today we tried to solve Symbol not found: __PyCodecInfo_GetIncrementalDecoder. First, we tried finding the reason for the error, and then we discussed how it could be solved.

I hope this article has helped you. Keep Supporting.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments