autosklearn installation. Error: No module named 'sklearn.metrics.classification' - scikit-learn

I'm trying to execute a script that uses Scikit and autosklearn on Ubuntu 20, python 3.8
I have followed the instructions to install sckit https://scikit-learn.org/stable/install.html and autosklearn installation https://automl.github.io/auto-sklearn/master/installation.html
However I'm getting
Exception ignored in: <function AutoML.__del__ at 0x7f37c6ee9160>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/autosklearn/automl.py", line 1380, in __del__
self._backend.context.delete_directories(force=False)
AttributeError: 'AutoMLClassifier' object has no attribute '_backend'
Traceback (most recent call last):
File "myscript.py", line 261, in <module>
import model_snow_magn_only_package
File "/myfolder/myscript.py", line 150, in <module>
clf = pickle.load(open(model_name, "rb"))
ModuleNotFoundError: No module named 'sklearn.metrics.classification'
I have tried other releases of these packages but without success.
Does anyone have an idea of which releases/packages to install to make it work?

Related

'Invalid syntax' error when importing torch (Linux)

I'm trying to install torch under miniconda and simple import torch gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 779, in <module>
from .serialization import save, load
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 18, in <module>
from typing_extensions import TypeAlias
File "/home/username/.local/lib/python3.8/site-packages/typing_extensions.py", line 880
if stripped_args
Interestingly, if I repeat import torch again the error message changes:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 249, in <module>
for name in dir(_C):
NameError: name '_C' is not defined
I'm not using notebooks, python version is 3.8.16, pytorch version is 1.13.1. Miniconda is installed in a local folder (it's a university server so I can only do it like this due to disk space restrictions), the server runs on Ubuntu.
What could possibly be the problem?
The only recommendation I found for similar problems is to install Cython but it didn't help.
Downgraded to python 3.6 and this somehow solved the problem.

ImportError DLL load failed while importing fasttext_corpusfile

When I try to import gensim, I get the below error:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\fasttext.py", line 264, in <module>
from gensim.models.fasttext_corpusfile import train_epoch_sg, train_epoch_cbow
ImportError: DLL load failed while importing fasttext_corpusfile: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\__init__.py", line 11, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\__init__.py", line 22, in <module>
from .fasttext import FastText # noqa:F401
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\fasttext.py", line 266, in <module>
raise utils.NO_CYTHON
RuntimeError: Compiled extensions are unavailable. If you've installed from a package, ask the package maintainer to include compiled extensions. If you're building Gensim from source yourself, install Cython and a C compiler, and then run `python setup.py build_ext --inplace` to retry.
My computer is Windows Server 2022 Data Center, python is 3.8.10, gensim is 4.2.0.
How can I solve this problem? Thank you for your help.
I re-installed gensim (gensim-4.2.0-cp39-cp39-win_amd64.whl) from https://pypi.org/project/gensim/#files, but still had the above problem.

Unable to parse valid xml in cpython 3.8

I'm trying to parse xml file in Python script, which is working inside the C++ application. When I'm trying to run this script:
import xml.etree.ElementTree as ET
root = ET.parse('somexml.xml' ).getroot()
I always receive an error:
RunScriptFail: Traceback (most recent call last):
File "xml\etree\ElementTree.py", line 1500, in __init__
File "<frozen zipimport>", line 259, in load_module
File "xml\parsers\expat.py", line 4, in <module>
ModuleNotFoundError: No module named 'pyexpat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "xml\etree\ElementTree.py", line 1503, in __init__
ModuleNotFoundError: No module named 'pyexpat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "xml\etree\ElementTree.py", line 1202, in parse
File "xml\etree\ElementTree.py", line 589, in parse
File "xml\etree\ElementTree.py", line 1505, in __init__
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
Error parsing script
But pyexpat.pyd exists in lib folder of cpython. How can I fix it? Or may be I can use some workaround for it?
Solution from Using SimpleXMLTreeBuilder in elementtree works for me
I found that needed pyexpat.pyd is not copied into distribution. I added it ad that resolved my issue

qgis ModuleNotFoundError: No module named 'PyQt5.pyqtconfig'

Traceback (most recent call last):
File "D:/Study/qgis3/QGIS/cmake/FindPyQt5.py", line 34, in <module>
import PyQt5.pyqtconfig
ModuleNotFoundError: No module named 'PyQt5.pyqtconfig'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Study/qgis3/QGIS/cmake/FindPyQt5.py", line 37, in <module>
import PyQt5.QtCore
ImportError: DLL load failed:
Found SIP version: 4.19
Traceback (most recent call last):
File "D:/Study/qgis3/QGIS/cmake/FindQsci.py", line 45, in <module>
from PyQt5.Qsci import QSCINTILLA_VERSION_STR
ImportError: DLL load failed:
CMake Error at cmake/PyQtMacros.cmake:22 (MESSAGE):
pyuic[4|5] not found - aborting
Call Stack (most recent call first):
CMakeLists.txt:714 (INCLUDE)
I have installed pyqt5 and SIP though pip3, but above problem still arises.

Theano Import Error, python 3.6 windows 10

I'm trying to import theano and I'm getting an import error.
I've seen common issues with theano relate to not having g++, mingw, or libpython installed. I can confirm I have all three installed. g++ 4.7.0, mingw 4.7, libpython 2.1, and theano 1.0.1.
Any suggestions on what to chase down next? I'm a little stumped.
When I run a simple python (3.6) file trying to import theano I get the following:
You can find the C code in this temporary file: C:\Users\CAVEJO~1\AppData\Local\Temp\theano_compilation_error_1b3hfusl
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 92, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\Projects\Pandas\housing_prices.py", line 4, in <module>
import theano
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\__init__.py", line 110, in <module>
from theano.compile import (
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
from theano.compile.mode import *
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\vm.py", line 673, in <module>
from . import lazylinker_c
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 127, in <module>
preargs=args)
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\cmodule.py", line 2359, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): The system cannot find the path specified.
.
I had the same issue, and it came down to missing dependencies.
This seemed to be the key for me:
conda install numpy scipy mkl-service libpython m2w64-toolchain
conda install -c conda-forge blas
See https://github.com/Theano/Theano/issues/6532 or more details.

Resources