기호를 찾을 수 없음 : __PyCodecInfo_GetIncrementalDecoder
Homebrew Python 2.7.11 (2.7.10에서)에서 업데이트 한 이후 갑자기 PyCharm IDE 콘솔에서 PyPi에 패키지 등록을 테스트 할 수 없습니다.
실행 ( "외부 도구"로)
python -B setup.py register -r pypitest
나는 지금 얻는다
Traceback (most recent call last):
File "setup.py", line 22, in <module>
from setuptools import setup
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.7/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 16, in <module>
from setuptools.depends import Require
File "/usr/local/lib/python2.7/site-packages/setuptools/depends.py", line 6, in <module>
from setuptools import compat
File "/usr/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
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
Process finished with exit code 1
진행 방법을 잘 모르겠습니다. 내 IDE의 콘솔 내에서 실행하는 경우에만이 문제가 발생합니다. 시스템 명령 줄 (OS X의 터미널)에서 직접 수행하면 문제가 없습니다.
OS X 10.11.3; Homebrew Python 2.7.11; PyCharm 5.0.3
tl; dr : 다음 중 하나를 수행하여이 문제를 해결합니다.
- 유형
hash -r python
, 또는 - 로그 아웃하고 로그인하십시오.
편집 : 내 관련 질문에 대한 답변으로 여기에서 무슨 일이 일어나고 있는지 명확하게 알 수 있습니다. 새 버전의 Python을 설치할 때 hash -r python
bash에 "캐시 된"위치를 python
실행 파일 로 재설정하도록 명령 을 실행해야 할 수 있습니다 .
내 경우에는, 내가 입력했다 python
나의이고, $PATH
에서 /usr/local/bin/python
. 그러나 bash
여전히 이전 캐시 위치를 사용하고있었습니다 /usr/bin/python
. 따라서 이전 실행 파일이 호출되었지만 새 경로가 sys.argv[0]
. 이는 이전 실행 파일이 실행 중이었지만 새 sys.executable
값으로 인해 모든 잘못된 모듈 ( io
모듈 포함 ) 이로드되었음을 의미합니다 .
나는 같은 문제가 있습니다. Python.org의 설치 프로그램을 통해 Python 2.7.11을 설치했습니다. 이상하게도이 문제는 OSX가 python
전체 경로를 사용하여 쉘에서 호출 할 때와 단어 만 사용하여 OSX를 실행하는 방법 사이의 미묘한 차이와 관련이있는 것 같습니다 python
.
그래서 나를 위해 이것은 작동합니다 (전체 경로를 통해 파이썬 호출 /usr/local/bin/python
).
$ which python
/usr/local/bin/python
$ /usr/local/bin/python -c "import io"
$
...하지만 그렇지 않습니다 :
$ python -c "import io"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
따라서 해결 방법으로 동일한 작업을 시도 할 수 있습니다.
다른 곳에서는 이 수수께끼 같은 행동에 대한 별도의 질문을 게시했습니다 . 어쩌면 단순히 호출 python
하면 2.7.11 실행 파일과 2.7.10 dylibs의 이상한 혼합이 호출 될 수 있습니다.
https://github.com/klen/python-mode/issues/634 에 따르면 :
나는 같은 문제가 있었지만 성공적으로 해결되었습니다. 제 경우에는 PYTHON_PATH가 지정되고 개발 환경 중 하나로 설정되었을 때 homebrew로 python과 vim을 컴파일했습니다. 여기서 io를 포함한 일부 라이브러리도 있습니다. 해결 방법은 간단했습니다. 새 터미널을 열고 사용자 지정 PYTHON_PATH가 없는지 확인하고 python을 제거하고 vim을 제거합니다. 둘 다 다시 설치하십시오.
과
문제 해결됨.
범인은 python 2.7.10에서 2.7.11로 업데이트 된 것입니다.
conda 패키지 제어를 사용하는 경우 "conda install python = 2.7.10"을 실행하면이 문제가 해결됩니다.
This doesn't give the root cause though. Since this happens with _io
, this looks like a bug in python 2.7.11 (unlikely, there would be a world-scale outcry and a prompt fix if it was) or some packaging bug or version mismatch specifically with the homebrew version (and maybe some related ones, too).
Try to import _io
in the console and if it succeeds, check if it was loaded from the same path.
Reinstall python.
brew unlink python && brew reinstall python
Secure the path
export PYTHONPATH=$PYTHONPATH:/usr/local/bin/
BACKUP and Change the order of "paths" file.
sudo nano /etc/paths
it seems, the order of paths, it is decisive to run python properly. In my case, the result was:
#sudo nano /etc/paths
/usr/bin
/usr/local/bin
/bin
/usr/sbin
/sbin
On my mac, path is like this.
$ which python
/usr/local/bin/python
Now I can run both:
$ /usr/local/bin/python -c "import io"
$ python -c "import io"
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so
file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5: /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
file with the _io.so
that you just found.
This happened to me as well in MacVim. I solved it by making sure :python print(sys.path)
is using system Python (e.g. /Library/Python/2.7/...
)
Since I installed MacVim via Homebrew, I just did that by:
Spawn a new shell that had
which python
->/usr/bin/python
. For my case I needed to remove thepyenv
line from my.bash_profile
. If you installed Python via Homebrew you may want tobrew unlink python
firstbrew reinstall macvim
Another quick workaround if you don't mind sticking with Python 2.7.10 is to specify the path of the Python interpreter executable that will be used for the virtualenv. On OSX that path is usually /usr/bin/python
:
virtualenv venv --python=/usr/bin/python
If your problem is caused by anaconda
, it is unnecessary to remove //anaconda
directory.
Just open your ~/.bash_profile
, find the line
export PATH="//anaconda/bin:$PATH
and comment it out, then restart your terminal session.
Can't add comment (?) so this just to share my exp., downgrade to 2.7.10 works fr me.
I got this error after a failed NLTK download, I needed to uninstall anaconda:
sudo rm -rf ~/anaconda
update PATH variable
This happened when I already had tried to create a venv in a folder, and mistakenly was trying to initialize a second one! So I just removed venv directory and re-ran the command. Very likely this is not the answer to this solution, but searching my error brought me here, so it may help some others who are stuck.
I solved this issue by removing the symbolic link that was in /usr/local/bin
and copying the actual python binary, that was pointed to by said link, there.
I had the same issue when I tried to use PyCharm. Solved by setting "python interpreter" in project configuration to point to the python virtual env I wanted to use, which was an Anaconda env. Somehow the interpreter path was missing the "anaconda" portion of ~/.../anaconda/.../_io.so. No need to uninstall anaconda.
참고URL : https://stackoverflow.com/questions/34386527/symbol-not-found-pycodecinfo-getincrementaldecoder
'Nice programing' 카테고리의 다른 글
Chrome DevTools를 열 때마다 기본적으로 "콘솔 드로어"를 숨기려면 어떻게해야합니까? (0) | 2020.10.22 |
---|---|
Htaccess : URL에서 후행 슬래시 추가 / 제거 (0) | 2020.10.22 |
문자열에서 선행 및 후행 공백 제거 (0) | 2020.10.22 |
CloudFlare 및 PHP를 통해 방문자 IP 주소 로깅 (0) | 2020.10.22 |
컴파일 타임에 런타임 다형성을 해결할 수없는 이유는 무엇입니까? (0) | 2020.10.22 |