6

I have found that running

pip install fbprophet --target=/tmp/foo --no-cache-dir

gives the following error: ImportError: No module named pystan

However if I remove either --target or --no-cache-dir options then it installs successfully. i.e. both of the following commands are successful:

  1. pip install fbprophet --no-cache-dir

  2. pip install fbprophet --target=/tmp/foo

Does anybody know why that's the case?

merv
  • 67,214
  • 13
  • 180
  • 245
N3da
  • 4,323
  • 5
  • 20
  • 22

1 Answers1

2

I'm sure the problem is neither in --target nor in --no-cache-dir. I tried both command in transient empty virtual environments (recreating a venv after every command) and got the error with pip install fbprophet --target=/tmp/foo.

I believe the problem is in fbprophet's setup.py: it imports pystan during build process without checking that it's available or installing it. I think it could be fixed by copying or moving pystan from requirements.txt to setup_requires.

I suspect you didn't get the problem because after pip install fbprophet --no-cache-dir you have pystan installed globally. Remove everything installed with the 1st command and retry the second one. Or try them in new empty virtual environments.

Send a pull request to fix the problem.

I also think you can install in 2 steps:

pip install --target=/tmp/foo --no-cache-dir pystan
PYTHONPATH=/tmp/foo pip install --target=/tmp/foo --no-cache-dir fbprophet
phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks. Created a pull request to see what the authors think. However there are still two issues: 1) I also ran `pip install fbprophet --target=/tmp/foo` in a new virtualenv and it was (is) successful. 2) I still get the same error with the 2-step installation you suggested (in a new virtualenv). The first `pystan` installation is successful, but installing `fbprophet` still gives the same error of `"ImportError: No module named pystan"` – N3da Sep 11 '18 at 17:52
  • correction: The second issue above was because I had to add `/tmp/foo` to `$PYTHONPATH`. (`pip list` wasn't showing `pystan` after the successful installation.) Once I do that the 2-step installation works. Back to your original theory: If I create a dummy package that has `setup_requires=['pystan'], install_requires = ['pystan', 'fbprophet']` in the `setup.py` file, shouldn't that also do the trick? It doesn't work either and I'm not sure why. – N3da Sep 11 '18 at 18:07
  • Oops, yes, sorry, I have to test my own commands. I updated the answer — added `PYTHONPATH` for the last command; this way `setup.py` knows where from to import `pystan`. – phd Sep 11 '18 at 18:51