handson-ml
handson-ml copied to clipboard
To create workspace directory on Windows
Hello I would like to know how I can create a workspace directory on Windows. I have installed Python 3.8 and have been trying to put the following function on it $ export ML_PATH="$HOME/ml" and $ mkdir -p $ML_PATH
but both of them are not working. I have tried the same on windows command prompt but still an error. Do I need to create this directory through GitHub prompt or by Anaconda prompt. I have installed both of them.
Secondly, how I can install virtualenv through Anaconda?
Lastly, when I am trying to upload the raw data of housing on Jupyter it shows error after housing = load_housing_data() housing.head() I will be looking forward to your advice.
Kind regards, Nishant
Hi Nishant,
Thanks for your question.
First, on Windows, I strongly recommend you install Anaconda, Python 3.7 version. TensorFlow does not work with Python 3.8 yet, and installation is much easier on Windows using Anaconda. You should probably uninstall Python 3.8 first, to avoid any conflict between the two.
The installation instructions in the book are meant for MacOSX or Linux, not Windows. The export and mkdir commands are meant to just create the directory in which you will work on your Machine Learning projects. The first line uses export to temporarily define an environment variable called ML_PATH that will contain the path of the directory to create, called ml and located in your home directory (on MacOSX or Linux, the HOME environment variable usually points to /home/your_login, so the new ML_PATH variable will be equal to /home/your_login/ml). The variable will cease to exist after the shell (terminal) is closed.
On Windows, you access an environment variable using %VARIABLE_NAME% instead of $VARIABLE_NAME. You must also replace export with set, and replace $HOME with %HOMEDRIVE%%HOMEPATH%. Indeed, as far as I know (I don't use Windows), there's no predefinedHOME environment variable on Windows, but instead there are two variables: HOMEDRIVE points to the drive of the home directory (typically C:) while HOMEPATH points to the home directory on that drive (typically \Users\your_login. Note that Windows uses backslashes instead of slashes.
Lastly, the mkdir command creates the directory. The -p option specifies that all parent directories should also be created if they don't exist. On Windows, you should use md instead of mkdir -p. So if you define ML_PATH to be C:\a\b\c\d\e, for example, then md %ML_PATH will create directories C:\a, C:\a\b, C:\a\b\c, C:\a\b\c\d, and C:\a\b\c\d\e.
If you want the environment variable to be permanent (not just the lifetime of the terminal window), then read these instructions on how to set environment variables permanently.
Once you install Anaconda, it's easier to use by opening the Anaconda Shell. It's like a normal shell, except it has the appropriate environment variables set for you, so anaconda commands will be directly accessible and functional.
Also make sure to install git.
Once you've opened the Anaconda shell, you can run these commands:
# Create the working environment
set ML_PATH="%HOMEDRIVE%%HOMEPATH%\ml" # or define this env variable permanently
md %ML_PATH%
cd %ML_PATH%
# Clone the project
git clone https://github.com/ageron/handson-ml.git
cd handson-ml
# Edit environment.yml
notepad environment.yml
At this point, you must use notepad to comment out the lines in environment.yml that are tagged as not working on Windows. Then save the file, exit notepad and go back to the Anaconda shell.
# Create the tf1 conda environment
conda env create -f environment.yml
# Activate the tf1 environment and start Jupyter
conda activate tf1
jupyter notebook
Once you're done with Jupyter, you can type Ctrl-C in the Anaconda shell window. You can type jupyter notebook to start Jupyter again. Once you close the Anaconda shell window, if you want to start Jupyter again, you must open an new Anaconda shell window and type:
set ML_PATH="%HOMEDRIVE%%HOMEPATH%\ml" # unless you defined this env permanently
cd %ML_PATH%
cd handson-ml
conda activate tf1
jupyter notebook
Hopefully this will fix the error your got with load_housing_data(). If not, please copy/paste the full stacktrace here.
Hope this helps.
Thank you very much for your help.
Nishant
Thanks a lot, that wa really helpful.
Thanks it was really helpful.
Had similar understanding issues with the linux commands to use in win10. Luckily, I found this thread. One additional question. For me "environment.yml" has no tagged incompatibilities with windows, at least not in the file itself. So what to do about it? For now i just irgnored it and continued with the following steps.