Trying to run fastai library under virtualenv, hit bcolz error

I tried running fastai under python3 + virtualenv (as opposed to Anaconda), however I ran into errors trying to import bcolz.

I documented the error on the bcolz repo:

But I’m wondering if anyone here knows of a workaround? Or should I just use Anaconda?

Yes you should install anaconda - why wouldn’t you? Either way install numpy before bcolz in a separate pip/conda install. I recall one of the bcolz dependencies is specified as xxx>=3.2. Hence if xxx is not installed it installs latest version which is not compatible with numpy.

In case it helps someone else:

I also ran into issues related to installing/building bcolz.

For me, the fix was to install the python-dev library.

# python2.7
$ sudo apt install python-dev
# python3
$ sudo apt install python3-dev
# python3.6
$ sudo apt install python3.6-dev

Then I could painlessly install fastai:

$ pipenv install fastai

I would highly recommend checking out pipenv as a modern alternative to conda, plus I believe pipenv is now actually maintained by PyPA. Besides automatically creating and switching virtual environments for you, pipenv also provides a more mature requirements management and “locking” system similar to npm — including python version requirements — and is probably a little more portable (I never had success using conda’s environment.yml across 2 different machines), though you may need to rm Pipfile.lock; pipenv install on a different system, due to the system-specific nature of python dependencies. :+1:



I’m trying to install fastai using pipenv and I’m getting the same timeout error reported here:

pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='', port=443): Read timed out.

I have no problem installing fastai on a regular venv. I’m using OSX but can you provide some hints on where to go?


This solves my problem.

conda install -c anaconda bcolz

Of course, I had to do some steps first. The detail is below.
1] first I had to create a new virtual environment with

conda create --force -n fastai python=3.7.3

fastai is the name of your virtual environment
python=3.7.3 can be changed to your preferred version but I recommend to use the latest version > 3.7
2] then install fastai

conda install -c pytorch -c fastai fastai

3] Activate the newly created environment

conda activate fastai

4] Finally, install bcolz under this environment

conda install -c anaconda bcolz