3

I am using MacOs Mojave and currently trying to run the project available on GitHub on this link. I have installed latest version of python(i.e. python 3.8) and currently facing issues while installing the requirements, mainly in scikit-learn. Either way I am getting the same error.

Kindly help me through out to run this project completely on my machine locally.

enter image description here

I've also raised an issue on the main GitHub page regarding this and still waiting for an adequate response.

When I tried to install cython according to the given instructions and available answer on stackoverflow I'm getting another big error page with python3.8 using command- pip3 install --upgrade cython as mentioned in an answer. I'm attaching that's error messages here. enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here This is the complete set of error that I'm getting after that. Thanks in advance if anyone can get me through this project with python3.8

Thanks VonC for resolving the installation of cython. Now another error that I'm getting while installing scikit-learn with python3.8 in my system is: scikit-learn installation error with python3.8 As answered by @VonC, I did tried to follow linkenter link description here and now while executing the command pip install --verbose --editable . I'm now getting another error here Please help me regarding this. I've installed LLVM OpenMP library using Homebrew

kostix
  • 51,517
  • 14
  • 93
  • 176
vinay
  • 67
  • 2
  • 11

2 Answers2

4

"no module named Cython" was seen in other projects: CellProfiler/centrosome issue 78 with various workarounds:

python3 setup.py install
# and/or
python3.6 -m pip install --upgrade cython
sudo python3.6 -m pip install --upgrade cython
# and/or
pip install --upgrade cython

If you're using python 2.7 or above, type on terminal: pip install --upgrade cython
This should work.
The error is probably because the cython version installed from pip is incompatible to the python version on your system.

If that leads to:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

Then check this question, and try and update XCode: xcode-select --install


Regarding the scikit-learn error, it is:

It seems that scikit-learn cannot be built with OpenMP support.

  • Make sure you have followed the installation instructions:

https://scikit-learn.org/dev/developers/advanced_installation.html

There is an issue about this error

Looks like it's the result of an error in sklearn/_build_utils/openmp_helpers.py
For me the test program ./test_openmp.c works as expected, but not in the building Scikit-learn process.

So, I just replace False to True in the line 111 in openmp_helpers.py (sed -i -e '111s/False/True/' e.g.).
As a result, I get normal building of Scikit-learn 0.21.3

But also, from instructions for Mac:

install libomp with Homebrew to extend the default Apple clang compiler.

I tried the second option to install libomp with Homebrew.
It worked like a charm.

If you see "File "setup.py" not found", that means the pip command was not executed in the correct folder.
If you are installing from sources, you should type the pip install --verbose --editable . (after a conda activate sklearn-dev) where you have cloned said sources (where you should see a setup.py)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • but pip3 install --upgrade cython generates another error here. – vinay Nov 14 '19 at 06:17
  • although it is working for python 2.7 but not for python 3.8. I've the project which is giving error when I'm trying to run it using python 3.8 and when I'm trying to run it over with python 2.7 it is giving a file error like .....(cfd_apriori) Mac:web kyvinay$ python manage.py runserver File "manage.py", line 14 ) from exc – vinay Nov 14 '19 at 06:36
  • Can you suggest something regarding that? If you can look out for the original project on GitHub please check that out and then the instructions would be better understandable for me. The whole project has been run over another old python version and now it's giving me headaches with python 3.8 – vinay Nov 14 '19 at 06:37
  • @vinay First, I suspect your project is mainly compatible with Python 3.x, not the [old obsolete python 2](https://pythonclock.org/). So errors are expected with Python 2. – VonC Nov 14 '19 at 07:28
  • @vinay Then, what is the error your have with an up-to-date pip3 (make sure to upgrare pip) and `pip3 install --upgrade cython`? – VonC Nov 14 '19 at 07:29
  • I've upgraded the pip3 to the latest version and yes I'm getting absolute same error as I've posted still I m going to copy-paste the error ...starting and ending portion of the shell. After running the command pip3 install --upgrade cython the error goes like this... Collecting cython Using cached https://files.pythonhosted.org/packages/9c/9b/706dac7338c2860cd063a28cdbf5e9670995eaea408abbf2e88ba070d90d/Cython-0.29.14.tar.gz Installing collected packages: cython Running setup.py install for cython ... error ERROR: Command errored out with exit status 1: – vinay Nov 14 '19 at 07:48
  • Please refer to the screenshot for the error https://i.stack.imgur.com/4AUFv.png – vinay Nov 14 '19 at 08:01
  • @vinay Do you have the end of that error output? That is generally where the interesting part is. – VonC Nov 14 '19 at 08:06
  • Please refer to the image for the end of the error output. https://i.stack.imgur.com/eAbD6.png – vinay Nov 14 '19 at 08:25
  • I've updated my question now after getting another error(after successful installation of cython). Please look into it. – vinay Nov 18 '19 at 08:55
  • Apologies for not upvoting the answer, I've done that but still I'm unable to run the project completely due to error while installing scikit-learn. – vinay Nov 18 '19 at 10:15
  • @vinay No problem. I meant that for your past question. – VonC Nov 18 '19 at 10:16
  • @vinay Did you try installing `libcomp`? Do you still get the exact same error? – VonC Nov 18 '19 at 10:16
  • Yes I did and I am now getting another error here, something like this, ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /Users/kyvinay Exception information: Traceback (most recent call last): File "/Users/kyvinay/opt/anaconda3/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in main – vinay Nov 18 '19 at 10:18
  • @vinay But what command did you typed? Di you follow https://scikit-learn.org/dev/developers/advanced_installation.html#macos? – VonC Nov 18 '19 at 10:20
  • I've installed libcomp and I'm following the instructions after that available at this link: https://scikit-learn.org/dev/developers/advanced_installation.html#compiler-macos So while trying to execute the command: pip install --verbose --editable . I'm getting the above error. – vinay Nov 18 '19 at 10:21
  • It means first I've to go to the folder where setup.py is present( to the environment where I've installed the project files) and there I've to run the command pip install --verbose --editable . to get it right and avoid the error causing due to setup.py ?? – vinay Nov 18 '19 at 11:20
  • @vinay Yes. If you run that command in a folder where there is no `setup.py` (for scikit), you will keep getting the error message you mentioned before. – VonC Nov 18 '19 at 11:26
  • I've a total of 204 setup.py files with different paths. Which directory should I choose exactly to run that command? If I'm installing with homebrew then do what and where. Should I choose the location where I've to install all the requirements to run the projects. Sorry but I'm very much confused here (as I've also installed anaconda and tried to build scikit-learn with that too and found the same error). Sorry but I'm very much newbie here. Thanks again for helping me upto here. – vinay Nov 18 '19 at 17:28
  • Thanks for helping me, I've installed the scikit-learn but now I'm getting another error while running the server. Which is : File "/Users/kyvinay/cfd_apriori/4th_umpire/web/scikit-learn/sklearn/preprocessing/_encoders.py", line 107, in _transform if n_features != len(self.categories_): AttributeError: 'OneHotEncoder' object has no attribute 'categories_' [19/Nov/2019 10:42:01] "POST /pre_pred/ HTTP/1.1" 500 79155 – vinay Nov 19 '19 at 11:10
  • I've checked it already and I think OneHotEncoder object does have attribute 'categories_' – vinay Nov 19 '19 at 11:40
  • @vinay That would be better addressed in a separate question, in order to focus on that particular problem. – VonC Nov 19 '19 at 11:55
  • Yes, I think so. Thank you very much. – vinay Nov 19 '19 at 12:29
0

You just need to first install scikit-learn. Use:

pip install -U scikit-learn

OR

pip3 install -U scikit-learn
seralouk
  • 30,938
  • 9
  • 118
  • 133