Setting up Anaconda virtual server for d3.js

In order to test d3.js files locally you need a virtual server. A virtual server lets you run web apps as if they were on a real server. This article will go through installation and setup of the Anaconda Python distribution and then how to start a virtual server with Anaconda. In the d3 book we use for this course WAMP server is reccommended as a virtual server. Wamp server is a windows only solution but apparently MAMP server can be used on a Mac as well as Windows.

Howevever I choose not to use any of these because I think Anaconda Python has a very easy to use virtual server, as well as a lots of useful libraries for scraping and data science.

If you own a Mac and don’t care about the other features of Anaconda you might not need to proceed with the installation. The reason is that Mac OS comes with Python installed. However if you have an old installation of Python (version 2.x) I reccommend installing Anaconda, also if you want some of the other studd Anaconda has to offer you can proceed.

First you should be able to check the Python version by starting you terminal and typing:

python --version

Here is the link to download and install Anaconda:

https://www.anaconda.com/products/individual

Windows users need to know if they have a 32-bit or 64-bit system. You can check this by opening a file explorer (Win + e) and then right click on ‘This PC’ and choose properties. Then you should be able to see if you have a 32 or 64 bit system. Most Windows pc’s these days are 64 bit.

If you own a Mac just choose the graphical installation unless you are comfortable using the command line.

The following procedure will be a bit different on Mac and Windows so if you own a Mac scroll down to the Mac walthrough.

Start a virtual server on Windows

You need to open Anaconda’s command line applicatio in order to start the virtual server.

Press Win key and start typing ‘Anaconda’. Click on ‘Anaconda prompt’.

You should see a black dialog box and will show the folder pathm probably ‘C:\WINDOWS\system32>’. In order to start a virtual server you need to navigate to a folder containing your .html files. You can start your virtual server in any parent forlder of the one you have your files in.

Open a file browser and naviagte to the folder where you want to start your virtual server. Click in the address field of the file browser and Copy it (Ctrl + C).

Go back to Anaconda prompt

type cd and then one blank space, and then Ctrl + V and hit Enter

You should now see that Anaconda has navigated to your d3 folder. If that is the case you can sarta a virtual server by typing (or copy-pasting) the followin in Anaconda Prompt:

python -m http.server 8888 &.

If you see this:

Serving HTTP on 0.0.0.0 port 8888 (http://0.0.0.0:8888/) …

That means you have started a virtual server.

Starting a virtual server on a Mac

I don’t personally use a mac, but the following recipee used to work for students in the class:

Navigate to so you can see the folder containing your html map files but not inside thet folder.

Open the terminal. type ‘cd ‘ DONT HIT ENTER!

Drag the folder containing the html files to the terminal. This can also be any folder higher up in the hierarchy than the one containing your html files.

Hit enter

python -m http.server 8888 &.

If it says ‘serving http…..’ you have started a virtual server.

Browse your virtual server with a web browser

Open your web browser an type the following addrress:

localhost:8888

You can now see you html files through the virtual server.