could i re-initilize the sklearn library - python

http://screencloud.net/v/cPBi
I had problem in importing the sklearn neighbors library (called "LSHForest").
the online example here did exactly the same I did when importing the LSHForest, but mine is not working :(
Not really sure what is possibility wrong. do I have to reinstall ubuntu (because i heared that reinstall python under ubuntu environment is not recommended)
thanks for all the great help

You most likely have an older version of scikit-learn. You can check the current version using:
python -c "import sklearn as sk; print sk.__version__"
If you're using 0.16.1, you should be able to import LSHForest.

Related

Ubuntu error — cannot import name 'gcd' from 'fractions'

I'm using Ubuntu to learn basic bioinformatics. I just downloaded multiqc using conda, but when I want to run multiqc, it returns:
enter image description here
I am very naive and don't know how to solve this problem. ANY help would be highly appreciated. Thanks
I think gcd was moved to the math pack in 3.9. See https://docs.python.org/3/library/fractions.html
Changed in version 3.9: The math.gcd() function is now used to normalize the numerator and denominator. math.gcd() always return a int type. Previously, the GCD type depended on numerator and denominator.
I suggest you create a virtual environment with 3.8 and try that. There are tons of tutorials on how to do this.
As Andrew said, Python 3.8 can be installed virtually. However, I just asked Conda to reinstall the older version of python (3.8), and now it's working perfectly.
This problem happens when you have an outdated version of the networkx package, which is a MultiQC dependency. You can fix it by updating this package:
conda install networkx=2.5.1
The next release of MultiQC (v1.11) will specify that at least this version of networkx is required, to ensure Python 3.9 compatability.
GitHub issue where this was tracked down: https://github.com/ewels/MultiQC/issues/1413

How to solve ImportError: dlopen(): Symbol not found:.... Expected in: flat namespace

Can anyone help me solve this issue?
ImportError: dlopen(/Users/......./venv/lib/python3.6/site-packages/recordclass/mutabletuple.cpython-36m-darwin.so, 2): Symbol not found: __PyEval_GetBuiltinId
Referenced from: /Users/......./venv/lib/python3.6/site-packages/recordclass/mutabletuple.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/......../venv/lib/python3.6/site-packages/recordclass/mutabletuple.cpython-36m-darwin.so
I'm using a Mac if that's of any relevance
I couldn't quite figure out what the issue was but I'm assuming __PyEval_GetBuiltinId was broken/uninstalled.
So all I did to fix this was pip uninstall recordclass and then pip install --no-cache-dir recordclass and it seemed to have worked
I encountered the same problem and found your question. I have an M1 MacBook, but I think we're encountering 2 problems.
At first, I had a similar error to yours:
ImportError> dlopen(): Library not found
What I did to fix this error was 'brew install ___' the library that was missing, in my case it was tesseract. After I brew installed it again I ran my script and got a new error. This time I had a
no suitable image found: imageXXX found but wrong architecture
So what I think may be happening is there is an underlying error with the compatibility between our M1 chips and the brew install-ed formulaes. I'm currently trying to find a solution. The first I'm going to try is resetting my installation from scratch and, if that doesn't work, look at alternatives. Ultimately I think what will solve the problem is installing from source like is described on the OpenCV website: https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html.
Hope this helped!
EDIT
I just finished uninstalling Homebrew completely and the reinstalling it from scratch, both casks, formulae, EVERYTHING! And it seems to work. I got both Tensorflow and OpenCV to work (they both printed their versions and I ran a simple camera test on OpenCV)
This issue is well described here. I had the same issue with the NetCDF4 library in the macOS M1 chip.
In my case (NetCDF4#1.5.8) installing the library using brew and pip didn't solve the problem as the provided package wasn't compatible with the M1 chip.
The issue will solve as mentioned in their Github in NetCDF#1.6.0.
In such cases, I recommend:
First make sure that you install dependencies of the library (in this case recordclass) that you are using in your system in case you are using a virtual environment, not just in the environment.
Second check if the wheel of the library meets your machine requirements.

Error import with 'shamilton_filter_log' from 'statsmodels.tsa.regime_switching._hamilton_filter'

I tried to compile MarkovSwitching.py from statsmodels (link description here) in python, but I have the follwoing error,
ImportError: cannot import name 'shamilton_filter_log' from 'statsmodels.tsa.regime_switching._hamilton_filter' (C:\Users\myuser\Anaconda3\lib\site-packages\statsmodels\tsa\regime_switching\_hamilton_filter.cp37-win_amd64.pyd)
And I don't kown how solve this. Furthermore, I upgrade the statsmodels using '' pip install statsmodels --upgrade'', but doesn't work.
I don't know how to solve this problem, any help is welcome!
Thanks!
It's very hard to tell from your description what might be going wrong, since there could be many problems with your setup.
It looks like maybe you have installed Statsmodels v0.10 via Conda or pip and have then downloaded the development version of markov_switching.py. The development version has new functions that v0.10 does not have, and this is my guess about why you are getting the error.
You might try installing the release candidate of v0.11, using: pip install statsmodels==0.11.0rc1.

Encountering Import Error DLL load failed constantly

I have been trying to intall scikit-learn and pytorch using their respective commands given in the docs:
The commands for installing PyTorch are:
1) pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl
2) pip3 install torchvision
The command for installing scikit-learn is:
pip install -U scikit-learn
Some background:
I am using Windows 8.1, Python 3.7.2. My pip is updated. I have also installed Anaconda for solving this using conda, but had zero luck!(Also, here I am running into 'conda' unrecognized error which is another story). Here are the paths my PATH variable holds.
PATH
C:\Users\satya\Anaconda3;
C:\Users\satya\Anaconda3\Library\mingw-w64\bin;
C:\Users\satya\Anaconda3\Library\usr\bin;
C:\Users\satya\Anaconda3\Library\bin;
C:\Users\satya\Anaconda3\Scripts;
C:\Users\satya\AppData\Local\Programs\Python\Python37\Scripts\;
C:\Users\satya\AppData\Local\Programs\Python\Python37\; C:\Users\satya\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
The Actual Problem:
The same commands for installation given above work perfectly fine on my other Windows 10, but, for my Windows 8.1 it gives this error which has become a real PITA
Import Error: DLL load failed The specified module could not be found
When I import sklearn or import torch I get the exact same error. All the time.
Back Story:
I have searched almost all the related questions I could find on Stackoverflow and Github for 6+ hours to help me solve this problem. But, none of the answers have helped till now and some haven't had an "understandable" answer. Maybe, its just a small fix, but now, I am choosing to post a question on SO.
My Question Again:
Can someone please help out and try to explain what I am missing out here? I really want to fix this error for good(and want to be in a position to fix it if I encounter it again). An elaborate answer would really help understand easily.
Thank You!
Please check your python build number with the following command.
conda list python
Python 3.7.2 with build number h8c8aaf0_2 has a solved issue.
If this is the case, an update will do.
conda update python

Wrong scikit-learn version installed?

I encountered the same
ValueError: scoring must return a number, got [...] (<class 'numpy.core.memmap.memmap'>) instead.
error as discussed in Q34857870.
Based on answers to this question, and my own research, I believe this issue to be fixed in scikit-learn version 0.17.1, though I'm still encountering it. Then I noticed something strange.
conda lists the right version.
$ conda list scikit-learn
packages in environment:
scikit-learn 0.17.1 np111py27_0
My Jupyter notebook gives the right version:
%load_ext watermark
%watermark scikit-learn
scikit-learn 0.17.1
But I get a different version when I check the version within my code:
import sklearn
print(sklearn.__version__)
0.17
I wouldn't think anything of this, except I'm still seeing a bug in 0.17 that should have been fixed in 0.17.1, so I'm wondering whether I'm using the wrong version somehow.
I'm wondering if it is somehow connected to Q30666685.
You probably have multiple versions of scikit learn installed. You can see where it is installed by using
print(sklearn.__file__)
and then simply delete that. In case if you are still having version troubles work within a virtual environment.

Categories