pip install options "no-cache-dir" and "target" don't work well together?

N3da picture N3da · Sep 11, 2018 · Viewed 7.7k times · Source

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?

Answer

phd picture phd · Sep 11, 2018

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