question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't find module "pync"?

See original GitHub issue

Hey there,

I’ve installed the plugin (and have python 2.7.10 installed via pyenv) as well as done a pip install pync, but on load of the plugin, this happens:

python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr:   File "/Users/colby/.weechat/python/autoload/notification_center.py", line 6, in <module>
python: stdout/stderr:     from pync import Notifier
python: stdout/stderr: ImportError: No module named pync
python: unable to parse file "/Users/colby/.weechat/python/autoload/notification_center.py"

I’m assuming it’s because it can’t find the pync package I’ve installed? What can I do to get it to recognize my pyenv Python install? It definitely is installed, because when I try it out via the Python REPL, I get this (with the notification appearing properly):

image

Hope you can help me out! Let me know if you need anything else from me.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
ghostcommented, Oct 26, 2017

@leoj3n I was about to give up on getting OS X notifications from Weechat! Thanks, you put me on the right track!

The trick is: “python” from homebrew must be installed BEFORE you install weechat via homebrew. Otherwise weechat links to macOS “python2” install, which lacks the ability to load all libraries.

I don’t use pyenv. Instead, I always use “python2/python3/pip2/pip3” prefixes to specify which version I want.

Here’s how I fixed my weechat which had been installed before I had homebrew’s python2:

brew uninstall weechat
brew install python3
brew install python
brew unlink python && brew link --overwrite python # make sure python links to python2
pip2 install --upgrade pip setuptools # upgrade to latest pip2
pip3 install --upgrade pip setuptools # upgrade to latest pip3
pip2 install pync
brew install weechat --with-perl --with-python --with-ruby --with-lua

After that, my weechat worked and was able to use pync!

So all that remained was to do this in weechat:

/script install notification_center.py
/script autoload notification_center.py

Success!

2reactions
leoj3ncommented, Jun 22, 2016

I have found this same issue with zsh+pyenv+weechat installed via Homebrew.

WeeChat is built using cmake: https://github.com/weechat/weechat/blob/master/Makefile.am#L58

I don’t really know much about cmake, but my guess is it “finds” the system python instead of pyenv.

Maybe we need to tell WeeChat’s cmake to use pyenv like this?

Can someone with more knowledge on the subject confirm whether or not the problem is indeed in how WeeChat builds itself, or maybe is it a problem with how Homebrew builds WeeChat? Certainly it’s not a problem with weechat-notification-center but not sure where to go next.

Also note that WeeChat recommends python version 2.7 over 3.x.

https://github.com/Homebrew/brew/blob/master/Library/Homebrew/language/python.rb#L20 https://github.com/Homebrew/brew/blob/master/Library/Homebrew/requirements/python_requirement.rb#L22

http://stackoverflow.com/questions/32018969/coexistence-of-homebrew-and-pyenv-on-macosx-yosemite

If I force the env var PYTHONPATH:

export PYTHONPATH="/usr/local/var/pyenv/versions/2.7.10/lib/python2.7/site-packages"

It finds pync but the error changes from ImportError: No module named pync to:

ImportError: dlopen(/usr/lib/python2.7/lib-dynload/_struct.so, 2): Symbol not found: _PyUnicodeUCS2_AsEncodedString

https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Homebrew-and-Python.md#homebrew-provided-python-bindings

https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHOME

Finally:

I just gave up on that and used Homebrew’s python and pip:

brew install python
pyenv global system 2.7.10 3.5.1
pip install --upgrade pip setuptools
pip install pync
brew uninstall weechat
brew install weechat --with-lua --with-perl --with-ruby --with-aspell --with-python

Works. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to install pync on mac - python - Stack Overflow
It seems that the package for pync in the Python Package Index does not work properly. Installing directly from the pync github repo...
Read more >
pync · PyPI
A simple Python wrapper around the terminal-notifier command-line tool (version 2.0.0), which allows you to send User Notifications to the Notification ...
Read more >
Python can't find module, even after pip install - Reddit
Python can't find module, even after pip install. I'm trying to import/use an ETL package, PETL, with import petl as etl.
Read more >
Why Can't Python Find My Modules? - Real Python
A common error that new Pythonistas will come across is that the packages they think they've installed are not actually being recognized by ......
Read more >
Notify yourself from Python — Javorové lístky - Honza Javorek
Then I often found myself watching funny cat gifs one hour later, ... With the pync library, you can send native macOS notifications ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found