Repository navigation
Description
I am building a singularity (like docker) container with the same method that has worked successfully many dozens of times over the past months. This method should ensure there are no old versions of anything around, and each package is installed from scratch. I use the following command to install software:
pip3 install --upgrade git+https://github.com/mfschmidt/PyGEST.git
My PyGEST package has the following line in setup.py:
install_requires=['pandas', 'numpy', 'scipy', 'statsmodels', 'humanize', 'requests', 'matplotlib', ],
When the installation happens, I get the following output:
Collecting git+https://github.com/mfschmidt/PyGEST.git
Cloning https://github.com/mfschmidt/PyGEST.git to /tmp/pip-req-build-5y9lbdvm
Collecting pandas (from pygest==0.8.3)
Downloading https://files.pythonhosted.org/packages/69/ec/8ff0800b8594691759b78a42ccd616f81e7099ee47b167eb9bbd502c02b9/pandas-0.23.0-cp36-cp36m-manylinux1_x86_64.whl (11.7MB)
100% |################################| 11.7MB 224kB/s
Collecting numpy (from pygest==0.8.3)
Downloading https://files.pythonhosted.org/packages/71/90/ca61e203e0080a8cef7ac21eca199829fa8d997f7c4da3e985b49d0a107d/numpy-1.14.3-cp36-cp36m-manylinux1_x86_64.whl (12.2MB)
100% |################################| 12.2MB 1.0MB/s
Collecting scipy (from pygest==0.8.3)
Downloading https://files.pythonhosted.org/packages/a8/0b/f163da98d3a01b3e0ef1cab8dd2123c34aee2bafbb1c5bffa354cc8a1730/scipy-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (31.2MB)
100% |################################| 31.2MB 752kB/s
Collecting statsmodels (from pygest==0.8.3)
Downloading https://files.pythonhosted.org/packages/67/68/eb3ec6ab61f97216c257edddb853cc174cd76ea44b365cf4adaedcd44482/statsmodels-0.9.0.tar.gz (12.7MB)
100% |################################| 12.7MB 882kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-f8u5f7do/statsmodels/setup.py", line 347, in <module>
from numpy.distutils.misc_util import get_info
ModuleNotFoundError: No module named 'numpy'
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-f8u5f7do/statsmodels/
ABORT: Aborting with RETVAL=255
Most of the advice I found online about this error seemed to be specific to Windows installations. I am building a Ubuntu-based container on a Ubuntu-based laptop.
To fix the problem, I changed the install to two lines instead of one, explicitly installing numpy prior to anything else.
pip3 install --upgrade --force-reinstall numpy \
&& pip3 install --upgrade git+https://github.com/mfschmidt/PyGEST.git
This tactic allows the build to succeed. But the problem is not solved. When I run the image, I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/pygest", line 48, in <module>
from pygest.algorithms import algorithms
File "/usr/local/lib/python3.6/site-packages/pygest/__init__.py", line 16, in <module>
from pygest.algorithms import correlate as corr
File "/usr/local/lib/python3.6/site-packages/pygest/algorithms.py", line 5, in <module>
import statsmodels.api as sm
File "/usr/local/lib/python3.6/site-packages/statsmodels/api.py", line 7, in <module>
from .regression.recursive_ls import RecursiveLS
File "/usr/local/lib/python3.6/site-packages/statsmodels/regression/recursive_ls.py", line 16, in <module>
from statsmodels.tsa.statespace.mlemodel import (
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/mlemodel.py", line 18, in <module>
from .simulation_smoother import SimulationSmoother
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/simulation_smoother.py", line 10, in <module>
from .kalman_smoother import KalmanSmoother
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/kalman_smoother.py", line 11, in <module>
from statsmodels.tsa.statespace.representation import OptionWrapper
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/representation.py", line 10, in <module>
from .tools import (
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/tools.py", line 207, in <module>
set_mode(compatibility=None)
File "/usr/local/lib/python3.6/site-packages/statsmodels/tsa/statespace/tools.py", line 59, in set_mode
from . import (_representation, _kalman_filter, _kalman_smoother,
ImportError: cannot import name '_representation'
When I open a shell inside the container and navigate to the source, I find that 'tools.py' is in the same directory with 'representation.py' but there are no files with underscores, '_representation.*'. When I look at the analogous folder on my host laptop (where things seem to be working) I have '_representation.cpython-35m-x86_64-linux-gnu.so'.
Can anyone help me to figure out why these seemingly necessary files are not being downloaded or built? How can I fix this, and how might we prevent it from happening to others? A stackexchange question was posted today with the same error, but the problem seems to differ from another like it.
Activity
mfschmidt commentedon May 17, 2018
I neglected to mention that my laptop is on Ubuntu 16.04's latest packaged python3 (python 3.5.2), while the container is using the docker python:3.6-stretch base image, with python 3.6.5.
mfschmidt commentedon May 17, 2018
Also, the same thing happens with the docker python:3.5-jessie base image, with python 3.5.5.
josef-pkt commentedon May 17, 2018
I didn't realize when checking the release that scipy is now also a build dependency.
Because we compile the statespace models conditional on the scipy version, scipy needs to be installed when we need to do the version check.
The scipy version during build needs to be on the same side of scipy 0.16 as the runtime version.
I.e. A scipy >=0.16 needs to be available during build to make binaries compatible with recent scipy.
When the wheels will be available then numpy and scipy don't need to be pre-installed, but they and pandas and patsy need to be listed separately as runtime requirement for statsmodels. (because statsmodels doesn't list requirements in the wheels.
mfschmidt commentedon May 18, 2018
First, thank you for your time and efforts in maintaining statsmodels. I enjoy using it and appreciate your efforts.
I'm not confident I completely understand the problem, due to my own ignorance about the packaging system. I'll do more reading on it. But I modified my setup to the following to make sure the dependencies are explicitly there before installing statsmodels.
The build is successful and the container runs without a problem. Invoking a shell inside the container reveals that the _representation.cpython-36m-x86_64-linux-gnu.so file exists along with several others that were missing before.
So, this solves my problem, but seems hackish that it's dependent upon manually installing a mysterious list of dependencies first. I'll do what I can to educate myself on the packaging system before I say any more.
Best wishes to you, and thank you for your time and help. I can move along with a functional tool tonight.
josef-pkt commentedon May 18, 2018
The explicit sequential install is what we use in our CI testing, and what I use locally.
The plain
pip install statsmodelsdoes not work in general, partially by intention, and part is because our setup is a bit messy and hasn't been properly adjusted for better handling of build dependencies.Most likely it will be better in the next statsmodels version, for one thing because we will not have compilation conditional on the scipy version anymore.
josef-pkt commentedon May 18, 2018
I'm glad it works, and thanks for the thanks.
I started to think that the only noteworthy features of this release is that pip install doesn't work out of the box.
TST: Adjust appveyor tolerance
TST: Adjust appveyor tolerance
TST: Adjust appveyor tolerance
TST: Adjust appveyor tolerance