Skip to content

Python Set up Guide

Setting Up Python 3.13, Virtual Environments, and Nexus Repository

πŸ“Œ Introduction

This guide walks you through setting up Python 3.13, configuring pip, and working with virtual environments. Additionally, it includes steps for integrating with a custom package repository (such as Nexus or PyPI mirrors).


πŸ”Ή Step 1: Uninstall Existing Python Versions (If Needed)

If you have older Python versions and want a fresh installation, uninstall them first:

  1. Open Control Panel β†’ Programs & Features β†’ Uninstall Python.
  2. Delete leftover Python folders manually:
    Terminal window
    C:\Users\YourUsername\AppData\Local\Programs\Python\
    C:\PythonXX\ # (If installed in Program Files)

πŸ”Ή Step 2: Download and Install Python 3.13

  1. Visit the official Python website and download Python 3.13.
  2. Run the installer and select Customize Installation.
  3. Ensure the following options are checked: βœ… pip βœ… Add Python to PATH βœ… Install for all users (recommended)
  4. Click Next and complete the installation.

Verify Installation

After installation, open Command Prompt and run:

Terminal window
python --version
pip --version

βœ… Expected Output:

Python 3.13.x
pip 23.x.x from C:\Python313\Lib\site-packages\pip (python 3.13)

πŸ”Ή Step 3: Configure pip with a Custom Package Repository (Optional)

If using a private package repository (e.g., Nexus, Artifactory, or a corporate mirror):

  1. Set the package index URL:
    Terminal window
    pip config set global.index-url https://your-custom-repo-url/
  2. Set trusted hosts:
    Terminal window
    pip config set global.trusted-host your-custom-repo-url
  3. Set global timeout:
    Terminal window
    pip config set global.timeout 60

To verify, try installing a package:

Terminal window
pip install pandas

βœ… The package should download from your configured repository.


πŸ”Ή Step 4: Setting Up a Virtual Environment

A virtual environment allows you to create an isolated Python workspace for your projects.

Create a Virtual Environment

Navigate to your project directory and run:

Terminal window
python -m venv myenv

βœ… If successful, it will create a folder named myenv.

Activate the Virtual Environment

  • Windows (Command Prompt):
    Terminal window
    myenv\Scripts\activate
  • Windows (PowerShell):
    Terminal window
    myenv\Scripts\Activate.ps1

Your terminal will now show (myenv) at the beginning of the prompt.

Install Packages Inside Virtual Environment

Terminal window
pip install requests numpy pandas

Verify installed packages:

Terminal window
pip list

To deactivate the virtual environment:

Terminal window
deactivate

πŸ”Ή Step 5: Running a Python Script

  1. Create a new Python file outside the virtual environment:
    Terminal window
    echo "print('Hello, World!')" > hello.py
  2. Run the script:
    Terminal window
    python hello.py

βœ… Expected Output:

Hello, World!

πŸ”Ή Step 6: Fixing β€˜Script Not Found in PATH’ Warnings

If you see a warning like:

The script f2py.exe and numpy-config.exe are installed in 'C:\Users\YourUsername\AppData\Roaming\Python\Python313\Scripts\'
which is not on PATH. Consider adding this directory to PATH.

Solution: Add the Path to Environment Variables

  1. Open System Environment Variables (sysdm.cpl β†’ Advanced β†’ Environment Variables).
  2. Find Path under System Variables and click Edit.
  3. Click New and add:
    C:\Users\YourUsername\AppData\Roaming\Python\Python313\Scripts\
  4. Click OK, restart your terminal, and retry your commands.

πŸš€ Conclusion

You have now successfully:
βœ” Installed Python 3.13
βœ” Configured pip with a package repository
βœ” Created and activated a virtual environment
βœ” Installed packages and ran a Python script

This setup ensures clean dependency management and avoids system-wide conflicts. Happy coding! 🎯