Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing Statsmodels API #856

Closed
Sinansi opened this issue Oct 21, 2020 · 1 comment
Closed

Importing Statsmodels API #856

Sinansi opened this issue Oct 21, 2020 · 1 comment

Comments

@Sinansi
Copy link

Sinansi commented Oct 21, 2020

It is always headache to import statsmodels.

I have the statmodels installed in the target environment but PyCall insist that is not there.

julia> sm = PyCall.pyimport("statsmodels.api")
ERROR: PyError (PyImport_ImportModule

The Python package statsmodels.api could not be imported by pyimport. Usually this means
that you did not install statsmodels.api in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

C:\Users\sinan\anaconda3\envs\py38\python.exe

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the statsmodels.api module.

One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia. As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the statsmodels.api module, you can use pyimport_conda("statsmodels.api", PKG),
where PKG is the Anaconda package the contains the module statsmodels.api,
or alternatively you can use the Conda package directly (via
using Conda followed by Conda.add etcetera).

) <class 'ImportError'>
ImportError('DLL load failed while importing ufuncs: The specified module could not be found.')
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\statsmodels\api.py", line 9, in
from . import regression
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\statsmodels\regression_init
.py", line 1, in
from .linear_model import yule_walker
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\statsmodels\regression\linear_model.py", line 40, in
from scipy import stats
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\stats_init_.py", line 388, in
from .stats import *
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\stats\stats.py", line 174, in
from scipy.spatial.distance import cdist
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\spatial_init_.py", line 102, in
from .geometric_slerp import geometric_slerp
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\spatial_geometric_slerp.py", line 8, in
from scipy.spatial.distance import euclidean
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\spatial\distance.py", line 121, in
from ..special import rel_entr
File "C:\Users\sinan\anaconda3\envs\py38\lib\site-packages\scipy\special_init
.py", line 633, in
from . import _ufuncs

Stacktrace:
[1] pyimport(::String) at C:\Users\sinan.julia\packages\PyCall\BcTLp\src\PyCall.jl:547
[2] top-level scope at none:1

julia>

@Sinansi
Copy link
Author

Sinansi commented Oct 22, 2020

The problem was solved by the following lines:

ENV["PYTHON"] = ""
Pkg.build("PyCall")

I was using an Anaconda Conda environment, but now switched to Julia Conda environment.
Not sure how that solved it. Perhaps, Conda.jl is more compatible with Julia than Anaconda Conda.

@Sinansi Sinansi closed this as completed Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant