python getting Symbol not found: __PyCodecInfo_GetIncrementalDecoder - python

I am trying to use selenium in python and I am getting the following error:
Symbol not found: __PyCodecInfo_GetIncrementalDecoder
>>> from selenium import webdriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/selenium/__init__.py", line 18, in <module>
from selenium import selenium
File "/usr/local/lib/python2.7/site-packages/selenium/selenium.py", line 25, in <module>
import httplib as http_client
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
>>>
OSX 10.11.1
python 2.7.10
I can't figure out if this is an El Capitan issue, python issue. Tried brew doctor and system is ready.

It turned out it was a python issue, after installing a new version of python. Running this solved the issue:
hash -r python

This problem is most probably caused by Brew Installed python.
The python official website provides downloads for macOS, you should download and install the official package.
The official installer will fix the python link automatic, then issue solved.

Related

Unable to import psutil in Python 3.7 (Import Error)

I am unable to import psutil when I activated python on my venv, its gives the following error message, which I cant resolve.
I tried to uninstall psutil and install psutil again but it still returns the same error.
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/__init__.py", line 157, in <module>
from . import _psosx as _psplatform
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psosx.py", line 16, in <module>
from . import _psutil_osx as cext
ImportError: dlopen(/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so, 2): Symbol not found: _kIOMasterPortDefault
Referenced from: /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Expected in: flat namespace
in /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Will appreciate if anyone knows how to resolve this issue, thanks.
Does it raise the same error when you activate the venv, open the virtualenv python interpreter and import psutil?
Another cause I can think of is when you name your script psutil.py and within that script you try to import the psutil module.
(see the post of Yong Wang: airflow error:AttributeError: module 'airflow.utils.log' has no attribute 'file_processor_handler')

Not being able to use turicreate

I am trying to use turicreate. I installed it on my device (sudo python2.7 -m pip install turicreate) And when I ran my code (in terminal on Mac), I got a long error message. I believe that the significant part is as follows:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/cython/cy_unity.so, 2): Symbol not found: _syslog$DARWIN_EXTSN
Here is the integrity of it for reference:
Traceback (most recent call last):
File "classifier.py", line 1, in <module>
import turicreate as turi
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/__init__.py", line 30, in <module>
from turicreate.data_structures.sgraph import Vertex, Edge
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/data_structures/__init__.py", line 18, in <module>
from . import sframe
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/data_structures/sframe.py", line 16, in <module>
from ..connect import main as glconnect
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/connect/main.py", line 13, in <module>
from ..cython.cy_unity import UnityGlobalProxy
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/cython/cy_unity.so, 2): Symbol not found: _syslog$DARWIN_EXTSN
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/cython/../libunity_shared.dylib (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/cython/../libunity_shared.dylib
What is the problem here?
This article provides a detailed explanation of setting up Python environment for popular ML packages on Mac - Machine Learning Compass

Why i got that problems when i run my script?

Hi, is there a solution for this error code ?
Traceback (most recent call last):
File "./weevely.py", line 2, in <module>
from core.terminal import Terminal
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/terminal.py", line 6, in <module>
from core.module import Status
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/module.py", line 14, in <module>
from core.vectorlist import VectorList
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectorlist.py", line 15, in <module>
from core.vectors import Os
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectors.py", line 11, in <module>
from mako.template import Template
ImportError: No module named mako.template
Thanks.
The answer is pretty self explainatory and with a google search you could have solved everything in seconds.
Here you have a how to install pip if you don`t have it: How do I install pip on macOS or OS X?
After this type in the terminal:
pip install Mako
as stated in the official website: http://www.makotemplates.org/download.html
If this doesn`t work you can manually download the Mako package here:
https://pypi.python.org/pypi/Mako/
Please, also read this carefully:
https://stackoverflow.com/help/how-to-ask

Error when importing python-docx?

When I do import docx with the python-docx module, I get this error:
Traceback (most recent call last):
File "/Userpath/script.py", line 19, in <module>
import docx
File "/Library/Python/2.7/site-packages/docx/__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "/Library/Python/2.7/site-packages/docx/api.py", line 14, in <module>
from docx.package import Package
File "/Library/Python/2.7/site-packages/docx/package.py", line 11, in <module>
from docx.opc.package import OpcPackage
File "/Library/Python/2.7/site-packages/docx/opc/package.py", line 12, in <module>
from .part import PartFactory
File "/Library/Python/2.7/site-packages/docx/opc/part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "/Library/Python/2.7/site-packages/docx/opc/oxml.py", line 12, in <module>
from lxml import etree
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxslt.1.dylib
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Reason: unsafe use of relative rpath libxslt.1.dylib in /Library/Python/2.7/site-packages/lxml/etree.so with restricted binary
Any idea what's going on here?
This is a problem with your lxml installation.
I expect you get the same answer in Python when you type in the line:
>>> from lxml import etree
Which means it's not related to python-docx, it's just trying to load a package that's not (or not properly) installed.
Best bet is to search on 'windows install lxml' and learn what you can, but the quick fix might be to uninstall whatever lxml you have and reinstall it from scratch using a binary distribution from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

ImportError: Module use of python26.dll conflicts with this version of Python

I use Python 3.2.3
Tonight I tried to install requests from http://docs.python-requests.org/en/latest/ by pip and easy_install, but it doesn't work. I have error when trying to import it. So I decided to use standard library urllib.request and see this error again
That is the traceback:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\__init__.py", line 52, in <module>
from . import utils
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\utils.py", line 12, in <module>
import cgi
File "E:\Python32\lib\cgi.py", line 38, in <module>
from email.parser import FeedParser
File "E:\Python32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "E:\Python32\lib\email\feedparser.py", line 27, in <module>
from email import message
File "E:\Python32\lib\email\message.py", line 17, in <module>
from email import utils
File "E:\Python32\lib\email\utils.py", line 28, in <module>
import socket
File "E:\Python32\lib\socket.py", line 46, in <module>
import _socket
ImportError: Module use of python26.dll conflicts with this version of Python.
So how can I fix this?
UPD: Solved. It was bug in SublimeREPL, reinstalled that package.
I had a similar problem when I was using PythonXY. The Spyder was not loading and it turns out another software OpenCAD had installed Python2.6 version and that was not letting my Python27.dll to not work. After uninstalling OpenCAD, I was able to run the software.
I was able to troubleshoot by first searching for python26.dll and found that this file was located in the OpenCAD folder location and that made me realize that this software was causing the issue.

Categories

Resources