ReneVolution / profanity-omemo-plugin

A Python plugin to use (axolotl / Signal Protocol) encryption for the profanity XMPP messenger
GNU General Public License v3.0
64 stars 14 forks source link

Cannot import OmemoState #18

Closed malt3 closed 7 years ago

malt3 commented 7 years ago

When trying to start profanity with the plugin loaded I get this error in my log:

03/02/2017 12:54:20: prof: INF: Starting Profanity (0.6.0dev.master.b768c8b)...
03/02/2017 12:54:20: prof: INF: Initialising chat logs
03/02/2017 12:54:20: prof: INF: Initialising groupchat logs
03/02/2017 12:54:20: prof: INF: Loading accounts
03/02/2017 12:54:20: prof: INF: Initialising UI
03/02/2017 12:54:20: prof: INF: Initialising XMPP
03/02/2017 12:54:20: prof: INF: Loading capabilities cache
03/02/2017 12:54:20: prof: INF: Initialising commands
03/02/2017 12:54:20: prof: INF: Initialising contact list
03/02/2017 12:54:20: prof: INF: Loading TLS certificates
03/02/2017 12:54:20: prof: INF: Initialising OTR
03/02/2017 12:54:20: prof: DBG: GPG: Found gpgme version: 1.7.0
03/02/2017 12:54:20: prof: ERR: ProfOmemoPlugin - Could not import OmemoState
03/02/2017 12:54:20: prof: INF: Failed to load plugin: prof_omemo_plugin.py
03/02/2017 12:54:20: prof: DBG: Resizing UI
03/02/2017 12:54:20: prof: INF: Starting main event loop
03/02/2017 12:54:20: stderr: ERR: Traceback (most recent call last):
03/02/2017 12:54:20: stderr: ERR:   File "/Users/malte/.local/share/profanity/plugins/prof_omemo_plugin.py", line 29, in <module>
03/02/2017 12:54:20: stderr: ERR:     import profanity_omemo_plugin.xmpp as xmpp
03/02/2017 12:54:20: stderr: ERR:   File "/usr/local/lib/python2.7/site-packages/profanity_omemo_plugin-0.0.1-py2.7.egg/profanity_omemo_plugin/xmpp.py", line 29, in <module>
03/02/2017 12:54:20: stderr: ERR:     from profanity_omemo_plugin.prof_omemo_state import ProfOmemoState, ProfOmemoUser
03/02/2017 12:54:20: stderr: ERR:   File "/usr/local/lib/python2.7/site-packages/profanity_omemo_plugin-0.0.1-py2.7.egg/profanity_omemo_plugin/prof_omemo_state.py", line 31, in <module>
03/02/2017 12:54:20: stderr: ERR:     from omemo.state import OmemoState
03/02/2017 12:54:20: stderr: ERR:   File "/usr/local/lib/python2.7/site-packages/python_omemo-0.1.0-py2.7.egg/omemo/state.py", line 26, in <module>
03/02/2017 12:54:20: stderr: ERR:     from axolotl.identitykey import IdentityKey
03/02/2017 12:54:20: stderr: ERR:   File "build/bdist.linux-x86_64/egg/axolotl/identitykey.py", line 3, in <module>
03/02/2017 12:54:20: stderr: ERR:   File "build/bdist.linux-x86_64/egg/axolotl/ecc/curve.py", line 8, in <module>
03/02/2017 12:54:20: stderr: ERR:   File "build/bdist.macosx-10.12-x86_64/egg/axolotl_curve25519.py", line 7, in <module>
03/02/2017 12:54:20: stderr: ERR:   File "build/bdist.macosx-10.12-x86_64/egg/axolotl_curve25519.py", line 3, in __bootstrap__
03/02/2017 12:54:20: stderr: ERR:   File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 22, in <module>
03/02/2017 12:54:20: stderr: ERR:     import io
03/02/2017 12:54:20: stderr: ERR:   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
03/02/2017 12:54:20: stderr: ERR:     import _io
03/02/2017 12:54:20: stderr: ERR: ImportError: dlopen(/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
03/02/2017 12:54:20: stderr: ERR:   Referenced from: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
03/02/2017 12:54:20: stderr: ERR:   Expected in: flat namespace
03/02/2017 12:54:20: stderr: ERR:  in /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Using macos 10.12.3 with profanity 0.6.0dev.master.b768c8b

ReneVolution commented 7 years ago

Did you just recently update Python?

pfannie commented 7 years ago

Same here with macOS 10.11.6 and Profanity 0.6.0dev.master.b768c8b.

I un- and reinstalled python a few times recently, so there might have been an update.

ReneVolution commented 7 years ago

@pfannie Did you restart your machine in between or at least your bash?

pfannie commented 7 years ago

@ReneVolution Yes, I did.

When I run /plugins python_version inside Profanity it shows Python 2.7.10, which is the one that originally shipped with the OS, neither Python 2.7.13 or Python 3.6.0 which I installed through homebrew. Even though python and python3 link to those respectively.

On the other hand, when trying to load the plugin, the error message says it's using the homebrew python.

By the way, I'm using iTerm2 Build 3.0.14, and zsh 5.3.1.

ReneVolution commented 7 years ago

A quick google search resulted in http://stackoverflow.com/questions/34861128/osx-using-bash-to-find-python-is-different-than-using-usr-bin-env-python.

Could you try that and report back?

pfannie commented 7 years ago

OK, so I followed python all the way back to /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7. I guess that's normal for the homebrew installation.

$ ls -l /usr/local/bin/python
lrwxr-xr-x  1  admin    34B Feb  5 19:18 /usr/local/bin/python -> ../Cellar/python/2.7.13/bin/python
$ ls -l /usr/local/Cellar/python/2.7.13/bin/python
lrwxr-xr-x  1  admin    54B Dec 17 21:05 /usr/local/Cellar/python/2.7.13/bin/python -> ../Frameworks/Python.framework/Versions/2.7/bin/python
$ ls -l /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x  1  admin     7B Dec 17 21:05 /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python -> python2
$ ls -l /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2
lrwxr-xr-x  1  admin     9B Dec 17 21:05 /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2 -> python2.7
$ ls -l /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
-rwxr-xr-x  1  admin    13K Feb  5 19:18 /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7

These other things all result in the same output:

$ /usr/local/bin/python -c "import sys; print sys.executable; print sys.version_info"
/usr/local/opt/python/bin/python2.7
sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)
$ /usr/bin/env python -c "import sys; print sys.executable; print sys.version_info"
/usr/local/opt/python/bin/python2.7
sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)
$ python -c "import sys; print sys.executable; print sys.version_info"
/usr/local/opt/python/bin/python2.7
sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)
ReneVolution commented 7 years ago

Did you also try hash -r python as stated in the accepted answer?

pfannie commented 7 years ago

Yes. This is what hash | grep python returns:

python=/usr/local/bin/python
python-config=/usr/local/bin/python-config
python2=/usr/local/bin/python2
python2-config=/usr/local/bin/python2-config
python2.6=/usr/bin/python2.6
python2.6-config=/usr/bin/python2.6-config
python2.7=/usr/local/bin/python2.7
python2.7-config=/usr/local/bin/python2.7-config
python3=/usr/local/bin/python3
python3-config=/usr/local/bin/python3-config
python3.6=/usr/local/bin/python3.6
python3.6-config=/usr/local/bin/python3.6-config
python3.6m=/usr/local/bin/python3.6m
python3.6m-config=/usr/local/bin/python3.6m-config
pythontex=/Library/TeX/texbin/pythontex
pythonw=/usr/local/bin/pythonw
pythonw2=/usr/local/bin/pythonw2
pythonw2.6=/usr/bin/pythonw2.6
pythonw2.7=/usr/local/bin/pythonw2.7

I also had a look at this question at SO: http://stackoverflow.com/questions/34386527/symbol-not-found-pycodecinfo-getincrementaldecoder. But for me python -c "import io" works fine, I guess, as I don't get any output.

ReneVolution commented 7 years ago

Weird ... what is the output of type python ?

pfannie commented 7 years ago

type python returns python is /usr/local/bin/python.

pfannie commented 7 years ago

I did some testing and by now I'm pretty sure that this is either an issue with homebrew or with profanity. I installed it from source and compared the config.log files with the homebrew installation and you can clearly see where the homebrew install "goes wrong":

configure:12411: Symlinking Python.framework to /Library/Frameworks/Python.framework
configure:12418: checking for python-config
configure:12434: found /usr/bin/python-config
configure:12446: result: yes
configure:12463: checking for python
configure:12481: found /usr/bin/python
configure:12493: result: /usr/bin/python
configure:12509: checking for a version of Python >= '2.1.0'
configure:12535: result: yes
configure:12566: checking for the distutils Python package
configure:12570: result: yes
configure:12584: checking for Python include path
configure:12600: result: -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
configure:12607: checking for Python library path
configure:12684: result: -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -lpython2.7
configure:12691: checking for Python site-packages path
configure:12697: result: /Library/Python/2.7/site-packages
configure:12704: checking python extra libraries
configure:12711: result: -ldl  -framework CoreFoundation 
configure:12718: checking python extra linking flags
configure:12725: result: -u _PyMac_Error /System/Library/Frameworks/Python.framework/Versions/2.7/Python
configure:12732: checking consistency of all components of python development environment

For some reason it finds the system python stuff, which is rather strange, but doesn't have anything to do with this plugin.

ReneVolution commented 7 years ago

Fixed this in a sense that OmemoState now comes with source of this plugin.