pyod fails to install using pip
mdlockyer opened this issue · comments
When attempting to install without nose, I receive the following error:
(PyVi) Michael:PyVi michael$ pip install pyod
Collecting pyod==0.5.0 (from -r requirements.txt (line 18))
Using cached https://files.pythonhosted.org/packages/c9/8c/6774fa2e7ae6fe9c2c648114d15ba584f950002377480e14183a0999af30/pyod-0.5.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/setup.py", line 2, in <module>
from pyod import __version__
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/__init__.py", line 4, in <module>
from . import models
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/models/__init__.py", line 2, in <module>
from .abod import ABOD
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/models/abod.py", line 17, in <module>
from .base import BaseDetector
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/models/base.py", line 27, in <module>
from ..utils.utility import precision_n_scores
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/utils/__init__.py", line 2, in <module>
from .utility import check_parameter
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/pyod/utils/utility.py", line 18, in <module>
from sklearn.utils.testing import assert_equal
File "/Users/michael/anaconda3/envs/PyVi/lib/python3.6/site-packages/sklearn/utils/testing.py", line 49, in <module>
from nose.tools import raises
ModuleNotFoundError: No module named 'nose'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-gjdzzane/pyod/
Also have the same issue when installing from source
Should also note that I'm attempting to install into an Anaconda environment running Python 3.6.5
Thanks for the feedback. I included the test files in the package which triggers "nose", even it is only listed as optional. I will submit a fix (possibly tonight) to remove test files in the package. Will comment again once that is ready. Yue
Sounds good!
Sorry I just noticed that another problem is pyod depends on sklearn...which uses nose for validation, see error message below.
If possible, I would suggest installing nose (by either pip install nose or use Requirments.txt). I will need to double check sklearn dependency, which may not be possible to fix from my end. If that is the case, I will have change 'nose' from optional to required...
from sklearn.utils.testing import assert_equal
File "/Users/michael/anaconda3/envs/PyVi/lib/python3.6/site-packages/sklearn/utils/testing.py", line 49, in <module>
from nose.tools import raises
Tried installing nose then installing Pyod. I get an issue here that comes from matplotlib. It's an Anaconda (or venv I assume) specific error because matplotlib wants python installed as a framework. It seems like at the moment Pyod won't work in an Anaconda env. Possibly something for a future version as I would assume a lot of people working with data science/ statistics would use Anaconda.
here is the backtrace for reference:
(PyVi) Michael:PyVi michael$ pip install pyod
Collecting pyod
Using cached https://files.pythonhosted.org/packages/c9/8c/6774fa2e7ae6fe9c2c648114d15ba584f950002377480e14183a0999af30/pyod-0.5.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/setup.py", line 2, in <module>
from pyod import __version__
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/__init__.py", line 4, in <module>
from . import models
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/models/__init__.py", line 2, in <module>
from .abod import ABOD
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/models/abod.py", line 17, in <module>
from .base import BaseDetector
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/models/base.py", line 27, in <module>
from ..utils.utility import precision_n_scores
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/utils/__init__.py", line 9, in <module>
from .data import generate_data
File "/private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/pyod/utils/data.py", line 16, in <module>
import matplotlib.pyplot as plt
File "/Users/michael/anaconda3/envs/PyVi/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Users/michael/anaconda3/envs/PyVi/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "/Users/michael/anaconda3/envs/PyVi/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 17, in <module>
from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/j4/_68f6f3j4d51_2smq2mh5hyh0000gn/T/pip-install-7z8033c1/pyod/
The issue you saw is specific to the virtual env Qt problem on mac, which is caused by matplotlib, and it is a lingering issue. The problem can be reproduced by:
import matplotlib.pyplot as plt
It throws error if you install the matplotlib with pip command in a mac conda virtual env... There are several fixes though.
- Workaround 1: "conda install matplotlib" first
- Workaround 2: https://stackoverflow.com/questions/29433824/unable-to-import-matplotlib-pyplot-as-plt-in-virtualenv
Using workaround 1, I managed to install pyod in mac virtual env and also succeeded in running examples. See the screenshot below:
To facilitate the installation, I also removed the use of matplotlib in the code (I do not remove it from dependency since example codes still need it) and publish a new version 0.5.2. You may want to give it a shot...
Let me know if the problem persists.
I think that similar solution to this can solve the first issue - sciunto-org/python-bibtexparser#111 (I can create a PR with this solution if you would like)
@tomron Thanks Tom. I did check the post and it is an interesting bug :)
The pip install issue in pyod is because I used a function "sklearn.utils.testing.assert_equal", which depends on nose.tools. Even I listed sklearn in requirements.txt, it still requires nose to be installed, which should have been installed because sklearn depends on nose. This bug would happen if a person installs sklearn first and then uninstalls nose. The requirement of sklearn is fulfilled but nose is not there.
So I fixed this bug by listing nose as one of the requirements in requirements.txt. Not sure if this is exactly the same bug you mentioned.
This issue is actually a mixture of several issues which should probably be separated to several issues.
As a user of your package I don't want to pre install myself any dependency I want the setup file to do that.
When you import pyod in the setup file it calls the init file which imports other files and if the required packages are not present it will fail. The fix I suggested will fix this issue (I also suggest to fix the dependencies' versions, some dependencies miss the version)
I received an error when i exported the pyod.models.hbos however i have successfully installed pyod in ananconda environment ,the error shows like 'No module named 'pyod.models'; 'pyod' is not a package'
@dksajgfaigfkja It should be working. I just tested it under Python 2.7 and Python 3.7 by initializing new env with conda. The command I used is:
conda create -n newenv python=2.7
conda activate newenv
pip install pyod
pip list <- make sure pyod is installed
python hbos_example.py
Thoughts:
- make sure env is correct
- use pip list to see whether pyod is installed
- reactivate the env if needed
@Hasakii-ghj I have the same problems. Did you solve this problem? Would you mind giving me some suggestions about this? Thank you so much.
@Lotus-Lian maybe try conda install? https://anaconda.org/conda-forge/pyod
@yzhao062 Thank you for your suggestion. But I used conda install. But it doesn't work.
@LLh-lihan, @Lotus-Lian: What is the name of your python file? If it is 'pyod.py', rename it. In this case you are importing your own script.
Make sure that python file name is not pyod.py
. if package name and file name are same, will face this kind of error.