Pymc3 no longer importing

Hello,

I’m not sure what happened between yesterday and today, but I’m no longer able to import pymc3. I keep getting the following error:

Traceback (most recent call last):

  File "<ipython-input-5-2e5c536b7c65>", line 1, in <module>
    import pymc3 as pm

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\pymc3\__init__.py", line 38, in <module>
    __set_compiler_flags()

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\pymc3\__init__.py", line 33, in __set_compiler_flags
    import theano

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\__init__.py", line 110, in <module>
    from theano.compile import (

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
    from theano.compile.mode import *

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\compile\mode.py", line 11, in <module>
    import theano.gof.vm

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\gof\vm.py", line 674, in <module>
    from . import lazylinker_c

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\gof\lazylinker_c.py", line 140, in <module>
    preargs=args)

  File "C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\pymc_env\lib\site-packages\theano\gof\cmodule.py", line 2411, in compile_str
    (status, compile_stderr.replace('\n', '. ')))

. collect2.exe: error: ld returned 1 exit statuseano/compiledir_Windows-10-10.0.18362-SP0-Intel64_Family_6_Model_85_Stepping_4_GenuineIntel-3.7.7-64/lazylinker_ext/mod.cpp:976: undefined reference to `__imp__Py_TrueStruct'Error' more undefined references to `__imp__Py_NoneStruct' followow

Is there a known fix to this? I’m running on windows in a spyder environment, with pymc 3.9.3, theano 1.0.5 on python 3.7.

This is somewhat a weird problem - could you try creating a new conda environment?

I created a new one and still got the same issue. Could it be something with the conda install m2w64-toolchain?

I created the environment, installed pymc3 via pip, then imported and got the warning about the toolchain. I then installed the toolchain and now I get this error.

Hi Jordan,
To build on Junpeng’s answer, can you try creating the new env solely with the conda-forge channel?

You can for instance copy-paste (and trim if you want) the environment-dev.yml file from the PyMC3 repo (the first line of the yml file sets the new environment’s name, which you probably wanna change), save it into your project’s repo and do conda env create -f environment-dev.yml, which will install everything from conda-forge automatically.

That way, we know python, PyMC, Theano and the C-compilers are all coming from the same source. Hope this helps :vulcan_salute:

2 Likes

Try

conda install m2w64-toolchain -c msys2
1 Like

thank you Alex. Unfortunately, when I installed from conda forge, the below pops up on the command line after the packages are extracted. This is from the line conda install -c conda-forge pymc3 from the get started page of PyMC3

C:\Users\JORDAN.HOWELL.GITDIR>SET DISTUTILS_USE_SDK=1

C:\Users\JORDAN.HOWELL.GITDIR>SET MSSdk=1

C:\Users\JORDAN.HOWELL.GITDIR>SET "VS_VERSION=15.0"

C:\Users\JORDAN.HOWELL.GITDIR>SET "VS_MAJOR=15"

C:\Users\JORDAN.HOWELL.GITDIR>SET "VS_YEAR=2017"

C:\Users\JORDAN.HOWELL.GITDIR>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"

C:\Users\JORDAN.HOWELL.GITDIR>set "MSYS2_ENV_CONV_EXCL=CL"

C:\Users\JORDAN.HOWELL.GITDIR>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"

C:\Users\JORDAN.HOWELL.GITDIR>set "CXX=cl.exe"

C:\Users\JORDAN.HOWELL.GITDIR>set "CC=cl.exe"

C:\Users\JORDAN.HOWELL.GITDIR>set "VSINSTALLDIR="

C:\Users\JORDAN.HOWELL.GITDIR>for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -version [15.0,16.0) -property installationPath`) do (set "VSINSTALLDIR=%i\" )

C:\Users\JORDAN.HOWELL.GITDIR>if not exist "" (for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -requires Microsoft.VisualStudio.Component.VC.v141.x86.x64 -property installationPath`) do (set "VSINSTALLDIR=%i\" ) )

C:\Users\JORDAN.HOWELL.GITDIR>if not exist "" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" )

C:\Users\JORDAN.HOWELL.GITDIR>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" )

C:\Users\JORDAN.HOWELL.GITDIR>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" )

C:\Users\JORDAN.HOWELL.GITDIR>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\" )

C:\Users\JORDAN.HOWELL.GITDIR>IF NOT "" == "" (
set "INCLUDE=;C:\PROGRA~2\IBM\SQLLIB\INCLUDE;C:\PROGRA~2\IBM\SQLLIB\LIB"
 set "LIB=;;C:\PROGRA~2\IBM\SQLLIB\LIB"
 set "CMAKE_PREFIX_PATH=;"
)

C:\Users\JORDAN.HOWELL.GITDIR>call :GetWin10SdkDir

C:\Users\JORDAN.HOWELL.GITDIR>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 exit /B 1

C:\Users\JORDAN.HOWELL.GITDIR>exit /B 0

C:\Users\JORDAN.HOWELL.GITDIR>for /F %i in ('dir /ON /B "\include\10.*"') DO (SET WindowsSDKVer=%~i )
The system cannot find the file specified.

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 (echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..." )  else (echo Windows SDK version found as: "" )
Windows SDK version found as: ""

C:\Users\JORDAN.HOWELL.GITDIR>IF "win-64" == "win-64" (
set "CMAKE_GEN=Visual Studio 15 2017 Win64"
 set "BITS=64"
)  else (
set "CMAKE_GEN=Visual Studio 15 2017"
 set "BITS=32"
)

C:\Users\JORDAN.HOWELL.GITDIR>pushd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
The system cannot find the path specified.

C:\Users\JORDAN.HOWELL.GITDIR>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16
The system cannot find the path specified.

C:\Users\JORDAN.HOWELL.GITDIR>popd

C:\Users\JORDAN.HOWELL.GITDIR>IF "Visual Studio 15 2017 Win64" == "" SET "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"

C:\Users\JORDAN.HOWELL.GITDIR>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\JORDAN.HOWELL.GITDIR>if errorlevel 1 exit /B 1

C:\Users\JORDAN.HOWELL.GITDIR>exit /B 0

I’ve never seen those before.

Did you create a new env with conda-forge?

conda create -n pymc_env python=3.8 m2w64-toolchain pymc3 -c msys2 -c conda-forge

Thank you for the reply @ahartikainen.

Same long error codes as pasted above. What does visual studio have to do with this? I keep seeing that appear.

Oh

conda install libpython

same-same. I’m goin to get IT to install python on the visual studio program that sits on my computer to see if that will work.

The msvc problem comes from situation, where your default compiler is not recognized as gcc. So either python or theano fails.

libpython should fix this for python, but I don’t know about theano.

Are you sure that pip and python are from the to same distribution?

Also, with jupyter, remember to restart after you install new stuff.

So I think it’s Theano. When I install piece by piece, it’s theano that throws the error.

1 Like

Btw, is that only occurring in spyder or also in python/ipython?

the install error is occuring in the anaconda command prompt

I have the same output when I try to install Theano on Anaconda. Have you found a solution?

No. I had to stop using it. Trying to figure out pyro.

Any solution to this ? I have the same problem and it’s so annoying, I can’t use pymc3 in my jupyter

Which versions are you trying to install? Have you tried following the steps in Installation Guide (Windows) · pymc-devs/pymc3 Wiki · GitHub (also available for osx and linux)?

Also struggling with a similar error as well. It looks like Theano is trying to use Visual Studio 2017, but I only have 2019 installed. Any guidance is very much appreciated!

Try upgrading theano using conda upgrade ‘your environment name’ theano