Fastai Installation Error - Maybe PyTorch

I had fastai working before on the following system.

OS: Windows 10
Python 3.6.5 Distribution: Anaconda

After reformatting the C: drive, trying to reinstall fastai is giving the following error:

Collecting torch<0.4 (from fastai==0.7.0)
  Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-931to5e5\torch\setup.py", line 11, in <module>
        raise RuntimeError(README)
    RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).

    Please follow the instructions at http://pytorch.org/ to install with miniconda instead.

I have tried the solution that worked for some (shapely and fiona) but it did not work for me. Any tips?

Hi,

Could you tell me the command you used to setup the environment?
I guess pip install fastai was used…

I think conda installation would work because it doesn’t use pip(PyPI).

1 Like

Hi @angert, thats correct what @crcrpar said,

If you use conda package manager to download pytorch it will just download , upgrade or downgrade some packages and just put the entire files of pytorch on the exact folder that anaconda/miniconda environment needs.

pip (python package manager) is possible but the packages installed by it may not find the dependencies that conda manages like cuda and others. In my understanding there is a big difference between a pytorch build for a conda environment and a pytorch build for a pure python environement.

You may find difficult to find pytorch with conda because normally conda search uses only the defaults channel you can include the pytorch channel too on the search.

try this to install:

conda install pytoch -c pytoch

you can also seach for pytorch on channel pytorch:

conda search pytorch -c pytorch

the pre-built Pytorch 0.4 on the defaults channel are not prepared for cuda and yet the ones that are (v0.3) are for cuda8.0.

If you have desire to use 0.4 for cuda 9.0 follow the instruction I described

Hi @crcrpar and @willismar,

I have tried both methods of installing fastai. The pip method fails as above.


The conda method appears to work (installs without errors). However it cannot be imported:

from fastai import *

causes

ModuleNotFoundError: No module named 'fastai'


When I inspect the folders in site-packages in the fastai environment or through the Anaconda Navigator, fastai is not present.

I have tried all the steps with and without conda activate fastai.


However, there are no errors when I run the following code in cmd:

cd Anaconda3/envs/fastai
conda activate fastai
python
from fastai import *

I am really not sure what I am missing…

Hi,

Thank you for sharing more information… and another question:
Could you tell me where you tried to import (not install) fastai?
I guess that was neither courses/dl1 nor courses/dl2.

I guess the solution is to run the command: pip install git+https://github.com/fastai/fastai.git after fastai environment is activated.

I drop an explanation below, but if you do not have the time, feel free to ignore.


Actually, conda installation of fastai repository does not install fastai as a python package.
What the conda installation instruction does is installing all the packages that fastai uses, e.g. pytorch, numpy, pandas, and so on.
I mean, the conda method does not add fastai to site_packages or python path of your environment.
This is why courses/dl1 and courses/dl2 directories have symbolic link to fastai and the below snippet did not raise any error.

Is that in a notebook? Have you created windows symbolic links instead of the “fastai” file in the folder your script is in?
Need to do that on windows. Open CMD as admin then
mklink /d fastai ../where/ever/fastai

Edit: just saw this problem was pointed out right above :smiley: anyways I’ll leave the command here

Woooowwww what a mess :smiley:

I keep seen this over and over again. This kind of confusion happens when you saw the package installing but not sure in what environment it was installed. Meaning standalone python or conda environment.

I suggest you start over. Remove Python if you have, remove Anaconda, restart the Windows machine

  1. Install Anaconda or Miniconda
  2. Download project: git clone https://github.com/fastai/fastai.git
  3. Move into root folder: cd fastai
  4. Set up Python environment: conda env update
  5. Activate Python environment: conda activate fastai or source activate fastai
  6. Install whatever package you need after have enabled the environment

Also notice that in fastai/courses/ (ml1 or dl1 or dl2) there is a shortcut that need to me made inside each of thie folders (in case of windows) to point the root folder of fastai/fastai so when you try to import it in any notebook will be like importing a module folder. Without the need to install the fastai package.

1 Like

@crcrpar Thanks for the suggestion but it still does not work. :confused:

I appreciate the extended explanation!

I tried running courses/ml1 and courses/dl1 as well as other notebooks in other directories. Nothing works.


@xeTaiz There already is a symbolic link in the \courses folder. I also tried creating the link in another directory.

Neither solves the problem unfortunately.


@willismar Tell me about it! I’ve gone through those steps four times now. :sweat_smile:

Anaconda is my only python installation and I only have one environment (fastai) besides the core conda environment.

Question about #1: Is there a particular folder in which it should be cloned? I have tried both in \Anaconda3\envs and C:\Users\user.


@all Is there a way to install fastai and use it with scripts in any directory? Thanks for all the help so far!

Oh, sorry to hear that.

I apologize that I don’t have any other idea…

1 Like

Woooowwww… that’s nice :sweat_smile: four times ?

You are definitely a winner :smiley:

Answer me the following questions so I can help you how to proceed better.
1-Do you have python3 or python2 standalone on the machine ?

2-If yes, look the environment variable for windows (User and General environments) and remove it from the path. Or Any python related path remove it. If you don’t want to loose that information I suggest you take notes and remove it from the system this can cause conflict with conda.

3-Do you have Anaconda3 on the same machine ?

@willismar I have no other python installation. The only environment variables are from conda:

C:\Users\user\Anaconda3
C:\Users\user\Anaconda3\Library\mingw-w64\bin
C:\Users\user\Anaconda3\Library\usr\bin
C:\Users\user\Anaconda3\Library\bin
C:\Users\user\Anaconda3\Scripts

They are under user variables and not system variables.

Thanks for taking the time for this!

This is your problem. It needs to be in the same dir as your notebooks.

1 Like

Also Note that windows has a different kind of smybolic link than what’s contained in the repo. Just to be sure, what you want to see is a folder shortcut to the proper fastai folder in your Windows Explorer. If you only see this fastai file containing …/…/fastai or so then it’s the wrong kind! Delete it and use the command mentioned above.

If there is no conflicts between versions as I imagined at first.

Now its only matters to clone and to the steps correctly as I mentioned earlier and redo the shortcuts for windows as professor Jeremy pointed out.

There is nothing much to say about it. I hope you get it right.

Thank you @willismar, @crcrpar, @xeTaiz and @jeremy for your help.

As an update, I managed to fix the issue using the following command:

(fastai)>python -m ipykernel install --user --name fastai --display-name “fastAI custom”

Source: Howto: installation on Windows

2 Likes

what i did was activate the (fastai) environment and inside the environment i ran the commands.
pip install fastai==0.7.0
pip install torchtext==0.2.3

The notebook doesnt give the module not found error anymore.
*(I opened a terminal for the environment from anaconda navigator)

This helped me a lot. Thanks!