1
votes

I'm currently using a KNN model that I constructed in an anaconda environment. The model was made using scikit-learn version 0.22.1 and pickle version 4.0. Wanting to access this script from a website, I moved all the code onto a web server on the same computer and used PHP to execute it from the command line.

When I do this, however, it relies on the regular python install. So to ensure that everything was kept in order across the board, I used pip to install all of the correctly versioned packages. But when I run the code from command line, it throws the following error:

Traceback (most recent call last):
  File "script.py", line 78, in <module>
    knn = pickle.load(file);
  File "sklearn\neighbors\_binary_tree.pxi", line 1180, in sklearn.neighbors._kd_tree.BinaryTree.__setstate__
  File "sklearn\neighbors\_binary_tree.pxi", line 1122, in sklearn.neighbors._kd_tree.BinaryTree._update_memviews
  File "sklearn\neighbors\_binary_tree.pxi", line 236, in sklearn.neighbors._kd_tree.get_memview_ITYPE_1D
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long long'

Given that I'm using both the same package versions and the same computer architecture, I can't understand why this error would be thrown.

1

1 Answers

0
votes

Turns out that I had python 3.7.6 installed in both instances, but had a 64-bit environment in which I developed my code and a 32-bit environment in which I deployed it. Uninstalling the 32-bit python and replacing it with 64-bit fixed the issue.