rdkit / homebrew-rdkit

Homebrew formula for rdkit
44 stars 19 forks source link

MacOS: ModuleNotFoundError: No module named 'rdkit' #50

Closed nsantini closed 4 years ago

nsantini commented 6 years ago

Ive installed with: brew tap rdkit/rdkit brew install rdkit --with-python3

and using like: from rdkit import Chem

Im getting: Traceback (most recent call last): File "data_structs.py", line 5, in <module> from rdkit import Chem ModuleNotFoundError: No module named 'rdkit'

UnixJunkie commented 6 years ago

same thing for em on my Mac...

nsantini commented 6 years ago

I fixed it by running: mkdir -p /Users/nico/Library/Python/3.6/lib/python/site-packages echo 'import site; site.addsitedir("/usr/local/lib/python3.6/site-packages")' >> /Users/<username>/Library/Python/3.6/lib/python/site-packages/homebrew.pth

Note: this is using python 3.6, change to your version, same with the username of your account

UnixJunkie commented 6 years ago

Why isn't the formula doing all this stuffs!!! How am I supposed to know about those... I'm really annoyed by this formula, it's not automatic.

nsantini commented 6 years ago

I discovered it by looking into others trying to install python modules with brew, the commands came from the "caveats" in the brew install output from one of the dependencies... so no particularly obvious

mcs07 commented 6 years ago

Interesting. This really shouldn't be necessary. By any chance are you trying to import rdkit from a different python installation than the homebrew one?

which python3 should give something like /usr/local/bin/python3

And if you run import sys;print(sys.path) in the python interpreter, you should see /usr/local/lib/python3.6/site-packages already in there.... (without needing to add the homebrew.pth file)

UnixJunkie commented 6 years ago

Thanks, I will try this.

hsiaoyi0504 commented 6 years ago

One thing I found is that when I tried to brew install rdkit --with-python3. I got this: Warning: rdkit: this formula has no --with-python3 option so it will be ignored!

hsiaoyi0504 commented 6 years ago

Forget that, it seems that my homebrew has some problem.

hsiaoyi0504 commented 6 years ago

My python3 works for Homebrew-rdkit, but I need to install through brew install rdkit/rdkit/rdkit --with-python3

hsiaoyi0504 commented 6 years ago

@UnixJunkie Is there any update of this ?

UnixJunkie commented 6 years ago

I will try at home

UnixJunkie commented 5 years ago

This can be closed.

UnixJunkie commented 5 years ago

I can repeatedly install rdkit using these steps:

pip3 install numpy
brew install --HEAD rdkit --with-python3 --with-inchi

This is no panacea, because it does not install a tagged release, but I can live with that for the moment.

Astrovicis commented 4 years ago

This is still an issue for me and my colleague, even with the suggestion from @UnixJunkie above.

UnixJunkie commented 4 years ago

@Astrovicis did the brew install work? Can you paste the full log of it. What is the output of 'which python3'?

UnixJunkie commented 4 years ago

These days, you can even install a recently tagged version of rdkit:

brew tap rdkit/rdkit
which python3 || brew install python3
pip3 install numpy
brew install rdkit --with-inchi
Astrovicis commented 4 years ago

brew install log:

==> Installing rdkit from rdkit/rdkit
==> Downloading https://github.com/rdkit/rdkit/archive/Release_2019_03_2.tar.gz
Already downloaded: /Users/maxhoward/Library/Caches/Homebrew/downloads/bfc63b18873a7e4cd38cb0629faa183240367686eef85d2251f3351efc03903e--rdkit-Release_2019_03_2.tar.gz
==> cmake -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D
Last 15 lines from /Users/maxhoward/Library/Logs/Homebrew/rdkit/01.cmake:
    boost_pythonConfig.cmake
    boost_python-config.cmake

  Add the installation prefix of "boost_python" to CMAKE_PREFIX_PATH or set
  "boost_python_DIR" to a directory containing one of the above files.  If
  "boost_python" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/local/lib/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
  /usr/local/Cellar/cmake/3.15.3/share/cmake/Modules/FindBoost.cmake:443 (find_package)
  CMakeLists.txt:255 (find_package)

-- Configuring incomplete, errors occurred!
See also "/tmp/rdkit-20190917-17742-10u5rc/rdkit-Release_2019_03_2/CMakeFiles/CMakeOutput.log".

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/rdkit/homebrew-rdkit/issues

These open issues may also help:
MacOS: ModuleNotFoundError: No module named 'rdkit' https://github.com/rdkit/homebrew-rdkit/issues/50
Installing RDKit on Mac OSX 10.10.2 with java and inchi https://github.com/rdkit/homebrew-rdkit/issues/25

which python3 output: /usr/local/bin/python3

UnixJunkie commented 4 years ago

ok, the problem is that the current version of boost/boost-python in homebrew is not compatible with rdkit. I don't know how to fix this easily.

UnixJunkie commented 4 years ago

This one would be nice to prevent this problem in the future: https://github.com/rdkit/homebrew-rdkit/issues/65

UnixJunkie commented 4 years ago

There was a related fix in the past: https://github.com/rdkit/rdkit/commit/738fc041629913a2d5b0352766f8b66b38679316 by @mcs07

UnixJunkie commented 4 years ago

I suspect the previous version in homebrew was working. I looked the history of this file: https://github.com/Homebrew/homebrew-core/commits/master/Formula/boost.rb That would be boost 1.70.0 or the one just before: boost 1.69.0_2. And I guess the boost-python3 formula's version must also match.

chenwenjie95 commented 4 years ago

I fixed it by running: mkdir -p /Users/nico/Library/Python/3.6/lib/python/site-packages echo 'import site; site.addsitedir("/usr/local/lib/python3.6/site-packages")' >> /Users/<username>/Library/Python/3.6/lib/python/site-packages/homebrew.pth

Note: this is using python 3.6, change to your version, same with the username of your account

with this I still have the same error. MacOS: ModuleNotFoundError: No module named 'rdkit' https://github.com/rdkit/homebrew-rdkit/issues/50

UnixJunkie commented 4 years ago

@chenwenjie95 try to use the rdkit install recipe from this PR: https://github.com/rdkit/homebrew-rdkit/pull/73 You need to do a git checkout, checkout the correct branch then add this as a tap to your homebrew.

UnixJunkie commented 4 years ago

@chenwenjie95 try this and tell us how it goes (with full log attached as a gist, if necessary):

brew update
which python3 || brew install python3
pip3 install numpy
brew unlink boost || echo boost_not_installed
brew unlink boost-python3 || echo boost-python3_not_installed
brew install rdkit --with-python3
UnixJunkie commented 4 years ago

Long time without new feedback so closing. If the problem persists, ask us the reopen the issue.

wenchengxucool commented 3 years ago

I still have this problem

UnixJunkie commented 3 years ago

Install the new rdkit recipe, not from this tap:

brew uninstall --force rdkit
brew untap rdkit/rdkit
brew update
brew install rdkit