0

I tried using "from sklearn.decomposition import PCA" on windows python 2.7 to my program, but the result was an error and it said like this:

Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
from sklearn.decomposition import PCA
File "C:\Python27\lib\site-packages\sklearn\decomposition\__init__.py", line 10, in <module>
    from .kernel_pca import KernelPCA
  File "C:\Python27\lib\site-packages\sklearn\decomposition\kernel_pca.py", line 14, in <module>
    from ..preprocessing import KernelCenterer
  File "C:\Python27\lib\site-packages\sklearn\preprocessing\__init__.py", line 8, in <module>
    from .data import Binarizer
  File "C:\Python27\lib\site-packages\sklearn\preprocessing\data.py", line 18, in <module>
    from scipy import stats
  File "C:\Python27\lib\site-packages\scipy\stats\__init__.py", line 343, in <module>
    from .stats import *
  File "C:\Python27\lib\site-packages\scipy\stats\stats.py", line 171, in <module>
    from . import distributions
  File "C:\Python27\lib\site-packages\scipy\stats\distributions.py", line 10, in <module>
    from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
  File "C:\Python27\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 16, in <module>
    from scipy.misc import doccer
  File "C:\Python27\lib\site-packages\scipy\misc\__init__.py", line 97, in <module>
    from .pilutil import *
  File "C:\Python27\lib\site-packages\scipy\misc\pilutil.py", line 21, in <module>
    import Image
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 27, in <module>
    from . import VERSION, PILLOW_VERSION, _plugins
ValueError: Attempted relative import in non-package

what's wrong with that? yesterday back then, I used that "from sklearn.decomposition import PCA" to my program and there's no problem whit that. help me please

Nomad
  • 1
  • 3
  • how did you try to run the code? did you use `python script.py` ? that version of sklearn do you have? – seralouk May 22 '18 at 13:59
  • as usual when trying to run a code, just F5. version of sklearn that I have is 0.19.1. the weird thing is when I tried to upgrade pip to latest version 10.0.1 (mine was version 9.0.1) and it failed, then system delete and downgrade the pip by itself to 8.0.1. does it have an effect to this error? – Nomad May 22 '18 at 15:47
  • i recommend to unistall scikit-learn, then do a `pip list --outdated | cut -d ' ' -f1 | xargs -n1 pip install -U` and finally install again scikit-learn – seralouk May 22 '18 at 17:37
  • @seralouk i tried "pip list --outdated | cut -d ' ' -f1 | xargs -n1 pip install -U" but it said _"cut" is not recognize as internal or external command_ – Nomad May 22 '18 at 21:34
  • by the way, after I uninstalled scikit-learn, the error message become like this: _Traceback (most recent call last): File "D:\lalaland\pokemon\bruh_imsickoftrying.py", line 1, in from sklearn.decomposition import pca ImportError: No module named sklearn.decomposition_ – Nomad May 23 '18 at 02:48
  • try `import sklearn` and then`sklearn.__version__`. What is the new installed version? Also, are you connected to a server? I see that your path is ` D:\lalaland ` – seralouk May 23 '18 at 07:47
  • I have sklearn version 0.19.1 and I don't think it connected to server, does it have an effect if it doesn't connect to the server? – Nomad May 25 '18 at 08:33
  • I have sklearn version 0.19.1 and I don't think it connected to server, does it have an effect if it doesn't connect to the server? – Nomad May 25 '18 at 08:33
  • what do you mean connected to server? are you running the script on a server ? – seralouk May 25 '18 at 08:48

0 Answers0