Closed jianghaizhu closed 7 years ago
If you do Conda.list()
, is it 1.7 that is installed? If so, then perhaps you can file an issue over there that Conda.update()
didn't update numpy
.
julia> Conda.list()
# packages in environment at /Users/zhuj6/.julia/v0.6/Conda/deps/usr:
#
asn1crypto 0.22.0 py27_0
cffi 1.10.0 py27_0
conda 4.3.22 py27_0
conda-env 2.6.0 0
cryptography 1.8.1 py27_0
enum34 1.1.6 py27_0
idna 2.5 py27_0
ipaddress 1.0.18 py27_0
mkl 2017.0.3 0
numpy 1.13.1 py27_0
openssl 1.0.2l 0
packaging 16.8 py27_0
pip 9.0.1 py27_1
pycosat 0.6.2 py27_0
pycparser 2.17 py27_0
pyopenssl 17.0.0 py27_0
pyparsing 2.1.4 py27_0
python 2.7.13 0
readline 6.2 2
requests 2.14.2 py27_0
ruamel_yaml 0.11.14 py27_1
scikit-learn 0.18.2 np113py27_0
scipy 0.19.1 np113py27_0
setuptools 27.2.0 py27_0
six 1.10.0 py27_0
sqlite 3.13.0 0
tk 8.5.18 0
wheel 0.29.0 py27_0
yaml 0.1.6 0
zlib 1.2.8 3
numpy was just upgraded to 1.13.1. But I still got the same error.
That's weird. Just to make 100% sure, could you please run using Conda; Conda.add("scikit-learn")
? I assume you'll get the same error, but then we can post it over there.
Also, in a fresh session, please try:
@pyimport sklearn.linear_model as lm
lm.LogisticRegression
because it looks like scikit-learn
is already installed.
I did Conda.add("scikit-learn")
and got the same error. The second command gave me the following error.
julia> using PyCall
julia> @pyimport sklearn.linear_model as lm
/Users/zhuj6/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/scipy/__init__.py:110: UserWarning: Numpy 1.8.2 or above is recommended for this version of scipy (detected version 1.7.0)
UserWarning)
RuntimeError: module compiled against API version 0xb but this version of numpy is 0x7
ERROR: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)) <type 'exceptions.ImportError'>
ImportError('numpy.core.multiarray failed to import',)
File "/Users/zhuj6/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Users/zhuj6/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/sklearn/base.py", line 10, in <module>
from scipy import sparse
File "/Users/zhuj6/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 229, in <module>
from .csr import *
File "/Users/zhuj6/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/scipy/sparse/csr.py", line 15, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
Stacktrace:
[1] pyerr_check at /Users/zhuj6/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
[2] pyerr_check at /Users/zhuj6/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
[3] macro expansion at /Users/zhuj6/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
[4] pyimport(::String) at /Users/zhuj6/.julia/v0.6/PyCall/src/PyCall.jl:370
How about:
julia> using PyCall
julia> pyimport("numpy")
PyObject <module 'numpy' from '/Users/cedric/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/numpy/__init__.pyc'>
julia> pyimport("numpy")[:__version__]
"1.12.1"
Aha.
julia> using PyCall
julia> pyimport("numpy")
PyObject <module 'numpy' from '/Applications/EMAN2/extlib/site-packages/numpy/__init__.pyc'>
julia> pyimport("numpy")[:__version__]
"1.7.0"
How do I solve it?
Not an expert on this, but https://github.com/JuliaPy/PyCall.jl#specifying-the-python-version are the instructions. If you have issues still afterwards, we can involve stevengj
My ENV["PYTHONPATH"]
was set by another script. After unsetting the variable, the problem was solved.
Here is the error.
The installed version of numpy is 1.13.0, but somehow
detected version 1.7.0
I didConda.update()
to update all packages.