Multimedia Notebook
 
STUDENT
 
FACULTY
 
SCHOOL
 
SUPPORT
 
PUBLIC
 
SIGNUP
DAILY QUIZ
 
     
  B U L L E T I N    B O A R D

Miniconda 3: Install Python 3.9, Tensor Flow, Spyder, Jupyter Lab, and PyCharm in Windows

(Subject: Data Analytics/Authored by: Liping Liu on 1/9/2025 5:00:00 AM)/Views: 4084
Blog    News    Post   

This guide consists of three parts. First, I will show you how to install, configure, and run Miniconda 3 with Python 3.9. Second, I will show you how to install important extensions and libraries such as Jupyter Lab, Pycharm, and Tensorflow. Third, I will show how to install standalone Python without Miniconda. Part 3 is followed if you don't want to install Miniconda (not suggested). Part 4 shows how to use Python in both command line and GUI tools such as Anaconda Prompt, Jupyter Lab, and PyCharm. 

Before you start, you may want to remove other Python installations to avoid version and registry conflicts. You can do so by going to Control Panel and Uninstall Programs.

Install Miniconda with Python 3.9

  1. Download minconda3: download Miniconda3-py39_23.5.2-0-Windows-x86_64.exe for the version that comes with Python 3.9.  
  2. Double click on the downloaded file, follow the direction, and choose to install for all users and file location as C:\ProgramData\miniconda3 
  3. Choose to install Miniconda to C:\ProgramData\miniconda3                         
  4. Check all the boxes in the next step and click Install button to finish.                        
  5. Add Anaconda binary code folder C:\ProgramData\miniconda3\condabin to the system PATH. Environment variable "Path" allow the system to find the program by searching the program in the specified paths. The following shows how to use the environment variable to add, delete, or modify a path. You can also download AddCondaPath.zip, extract AddCondaPath.bat file, right click on the batch file to run as administrator instead of following manual steps. 
    1. click on the search box and type "env" and choose "Edit the system environment variables" to open System Properties.                  
    2. Click on "Environment Variables" button 
    3. Note that there are two different sets of environment variables (see below). The top one "User Variables" is for the current user and the lower one "System Variables" is for all the users of your computer.   
    4. If Path variable does not exist, click New button and enter the name "Path" (see the photo below) and then enter "C:\ProgramData\miniconda3\condabin" as Variable value or press Browse Directory button to find the program's folder.
    5. If the "Path" variable already exists, press Edit button and you will see a list of paths that are currently in place. To add a new path, click on New button and you you will see a new black entry in the list. Enter "C:\ProgramData\miniconda3\condabin" or click "Browse ..." button to navigate to the location.           
    6. Press a few OK buttons to dismiss dialog boxes to close System Properties.
    7. Finally, you will need to log out and re-log in to make the variable effective.

Installing Tensor Flow for R

 Note the following before running the commands: 

  • Tensor Flow packages have compatibility issues with a few other packages such as SciPy, Spyder, etc. In particular, I found that Tensor Flow will not work in R if it is installed along with scipy, pandas, spyder package. So I suggest creating a separate virtual environment with Tensor Flow to be shared with R
  • All the commands should run without any warnings or errors. If there is any, go back to the prior steps to check if some steps were not performed or performed incorrectly. 
  • If you want to create a new virtual environment with support for advanced NVidia GPU acceleration, follow the follow-up guide.
  • Tensor Flow will not run on some newer lightweight laptops with ARM processors. Other libraries and tools have been tested to be working. 

Click Windows menu, right mouse click on Anaconda Powershell Prompt and choose to Run as Administrator:

Run the following commands one by one to create a new virtual environment called r-tensorflow and install required packages in it. 


conda update -n base -c defaults conda

conda create
--name r-tensorflow python=3.9

conda activate r-tensorflow

conda config --add channels defaults

C:\ProgramData\miniconda3\envs\r-tensorflow\python.exe -m pip install --upgrade pip

pip install tensorflow==2.10

pip uninstall numpy

        conda install numpy==1.26.4

Now you should be able to test if TensorFlow package is installed correctly by running the following command:
        python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"


You can also type python and go to python environment and verify it using the following:
     
        from tensorflow.python.client import device_lib
        print(device_lib.list_local_devices())

STOP: If the above test is successful, you may stop now if you just want to install Tensor Flow for R. Follow Install Tensor Flow for R to finish setup for R.

Remove Virtual Environment

In case you need to remove the virtual environment "tf", first exit out of tf environment using command "conda deactivate".
To list all environments, use command "conda env list". To remove the "tf" environmenent,
conda remove --name r-tensorflow --all
 
Installing Tensor Flow and IDE Tools for Machine Learning in Python

If you want to do machine learning using Tensor Flow in Python, follow the following to install a new conda environment and
additional python libraries for data sciences in Python and graphical interactive development environments.

First, you need to create a new virtual environment, for example, tf, as above using the code below:

conda update -n base -c defaults conda
conda create --name tf python=3.9

conda activate tf

C:\ProgramData\miniconda3\envs\tf\python.exe -m pip install --upgrade pip

pip install tensorflow


The following commands install
additional packages such as libraries for data science and analytics and GUI tools
such as Spyder and Jupyter Notebook to run Python.    

conda install pandas

conda install scipy

conda install scikit-learn

conda install seaborn

conda install matplotlib

conda install spyder  

conda install notebook

 

Now you can type "spyder" command to open Spyder IDE or "jupyter lab" to open Jupyter Notebook. 
For Jupyter Notebook, change the directory to the root directory by using command "cd c:\" before
the command "jupyter lab" so that you can save and open notebooks to your desired locations.

For example, type "jupyter lab" to open Jupyter Notebook and to run the same commands to
test Tensor Flow library there:
      from tensorflow.python.client import device_lib
        print(device_lib.list_local_devices())

In the future, to run Python with Tensor Flow, make sure to open Anaconda Prompt from
Windows menu, and then go to the "tf" virtual environment with the command:
    conda activate tf

PyCharm is another popular IDE for machine learning. You can download PyCharm Professional
from https://www.jetbrains.com/pycharm/download/?section=windows. Instructors and students may
apply for a free license for educational user from the company: https://www.jetbrains.com/academy/teaching/.

Installing PyTorch

If you want to do machine learning using PyTorch in Python, follow the following to install a new conda environment and
additional python libraries for PyTorch without using GPU accelerator.

First, you need to create a new virtual environment, for example, torch, as above using the code below:

conda update -n base -c defaults conda
conda create --name torch python=3.9

conda activate torch

Then, go to https://pytorch.org/get-started/locally/ to create a command for your installation. For example, if I choose Stable Build 2.6 for Windows and CPU compute platform, then the command is: 
        pip3 install torch torchvision torchaudio

Test the installation by going to python and run the following code:

import torch

print(torch.cuda.is_available()) # Should return True if CUDA is set up properly

print(torch.cuda.get_device_name(0)) # Prints the name of your GPU


Install Standalone Python 3.9 (without Miniconda)

Install Python in Windows:

  1. Go to https://www.python.org/downloads/release/python-390/ and download Python 3.9 for Windows 64-bit (later versions may not work for Tensor Flow package). 
  2. Double click to install Python and choose Custom Installation for all users. Check
    Add python.exe to PATH box.
  3. Select all optional features in the next screen if you choose customized installation 
  4. Select Install Python 3.9 for all users for customized installation and add Python to environment variables
  5. Press Install to finish installing Python

Install Jupyter Lab for Python:

  1. Run CMD as Administrator
  2. To check your Python installation, type command: python --version
  3. Type following commands to install Jupyter Notebook and Jupyter Lab: 
    pip install notebook
    pip install ipykernel
    python -m ipykernel install
    pip install jupyterlab

Install Tensor Flow for Python:

   pip install tensorflow

Install Python Libraries:

You may also try to install packages using pip, for example, openpyxl package for managing Excel data and Pillow for pictures: 

pip install openpyxl
pip install Pillow

Test Python Installations:
  1. To open JupyterLab, type command: jupyter lab in Windows Command Line
  2. Try to run the following Python code to copy a picture named A11.jpg into the A1 cell of your Excel file: 
    import openpyxl
    from openpyxl.drawing.image import Image
    # Open the workbook and select the worksheet
    workbook = openpyxl.Workbook()
    worksheet = workbook.active
    # Load the image file
    img = Image('c:\\temp\\A11.jpg')
    # Add the image to the worksheet at cell A1
    worksheet.add_image(img, 'A1')
    # Save the workbook
    workbook.save('c:\\temp\\photo.xlsx')

 

Use Python 

To use Python in command line tools, go to Windows start menu, and open Anaconda Prompt (don't use Windows Prompt). You can type "python --version" to check if the python is installed.

To go to a special virtual environment such as "tf" that we installed above, type command

conda activate tf

To install new packages such as "openpyxl", use the command

conda install openpyxl

To run python code, either go to Python command line environment by typing

python

or go web-based environment by typing

  jupyter Lab

or Windows environment by typing

spyder

You can also install and configure PyCharm, which supports creating virtual environments for Python with Conda. The following procedure applies to all supported operating systems. Use the platform switcher at the top of this page to view shortcuts specific to your operating system.


           Register

Blog    News    Post
 
     
 
Blog Posts    News Digest    Contact Us    About Developer    Privacy Policy

©1997-2025 ecourse.org. All rights reserved.