Start today!

How to start working with Python under Windows 10

Silviu Matei
4 min readSep 17, 2020

--

I am starting this series of notes on how I set up my environment and then started working with data using Python, both to have it documented for myself and also to help others. Before I start, a note to say that I am using Windows 10 Pro x64, on a personal laptop with 4 cores of Intel i7–7Y75 CPU @ 1.30 GHz and 1.6GHz on the mainboard.

  1. Installing Python: after several attempts with Anaconda, I ended up installing MiniConda. There are different versions, make sure you choose the right one for your system. I chose the version with Python 3, rather than 2. If one needs Python 2 later, it can be installed in a separate conda environment.

I installed MiniConda just for the current user to avoid issues with admin-level authorisations and left everything else to default.

Then I added Conda to the Windows path in order to be able to call Conda in any cmd or Windows shell. See here how to do it.

Next, I created a Conda environment because for one of my projects I need Python 3.6 exactly. Check here on how to create an environment.

I actually ran this code to create my environment py36 containing the necessary packages to run python 3.6

conda create --name py36 python=3.6

Next, Jupyter notebooks are needed as a preferred choice for development (when not using Google Colab). Just in case they are not already installed, you can easily do so with

pip install jupyter

To check if the Jupyter notebooks are installed, open a cmd and type:

jupyter notebooks

If the package is installed, it will open your default browser with a listing of the files in the default environment file deposit.

Coming back to the environment:

  1. It may be a tricky thing but if you need to run an environment — meaning that you need to run a python version different from the one of your base Miniconda installation — then, you will want to go inside the environment to install or update your packages. In order to do so — and assuming you added Conda to your system path — open the shell (Windows cmd) and run “conda activate myenv”. Since my environment is called py36, I would write “conda activate py36”. After you install or update the packages, in order to exit the environment, type in “conda deactivate”.
  2. More importantly, if you have your environment installed and you want to work inside it and have direct access to your files, here is a trick to quickly power up the environment and the jupyter notebooks platform.

Open a notepad file and write inside:

C:
cd C:\path\to\the\folder\where\your\files\are
call conda activate py36call jupyter notebookpause

Then save the file with .bat extension instead of the default .txt.

When you want to launch jupyter notebooks, double click on the .bat file rather than running the windows cmd->conda activate->jupyter notebooks commands.

I guess this is it to get anyone started with using python and jupyter notebooks.

Since I have already mentioned the packages, it may be important to describe the philosophy of Python: an open platform made of a miriad of modules. One installs Miniconda for the basic Python executables and modules and then keeps adding to this base as needed. Each version of a module works with a specific version of Python (or more than one). The point is that it is common for a module/package not to work with your version of Python — that is the reason why Conda enables you to create environment so that you can run your preferred programs in the Python version they are built for. For Windows users, this is similar to the fact that you need a particular version of a software to work on Windows 10. For the sake of argument, a Netscape Communicator (!), built for Windows ’95, would absolutely not work under Windows 10. In a similar vein, an Acrobat Pro version X built for Mac or a Unix system, will not work under Windows 10. From this perspective, the Python version of your environment acts as the development system and imposes restrictions on the packages and versions of the modules/packages you can use.

Here are some other useful links:

  1. To install Miniconda: https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html
  2. To manage packages: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html
  3. How to create batch files in Windows: https://www.windowscentral.com/how-create-and-run-batch-file-windows-10

--

--