Python Set up Guide
Setting Up Python 3.13, Virtual Environments, and Nexus Repository
Section titled โSetting Up Python 3.13, Virtual Environments, and Nexus Repositoryโ๐ Introduction
Section titled โ๐ 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)
Section titled โ๐น Step 1: Uninstall Existing Python Versions (If Needed)โIf you have older Python versions and want a fresh installation, uninstall them first:
- Open Control Panel โ Programs & Features โ Uninstall Python.
- 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
Section titled โ๐น Step 2: Download and Install Python 3.13โ- Visit the official Python website and download Python 3.13.
- Run the installer and select Customize Installation.
- Ensure the following options are checked:
โ
pip
โAdd Python to PATH
โInstall for all users
(recommended) - Click Next and complete the installation.
Verify Installation
Section titled โVerify InstallationโAfter installation, open Command Prompt and run:
python --versionpip --version
โ Expected Output:
Python 3.13.xpip 23.x.x from C:\Python313\Lib\site-packages\pip (python 3.13)
๐น Step 3: Configure pip with a Custom Package Repository (Optional)
Section titled โ๐น Step 3: Configure pip with a Custom Package Repository (Optional)โIf using a private package repository (e.g., Nexus, Artifactory, or a corporate mirror):
- Set the package index URL:
Terminal window pip config set global.index-url https://your-custom-repo-url/ - Set trusted hosts:
Terminal window pip config set global.trusted-host your-custom-repo-url - Set global timeout:
Terminal window pip config set global.timeout 60
To verify, try installing a package:
pip install pandas
โ The package should download from your configured repository.
๐น Step 4: Setting Up a Virtual Environment
Section titled โ๐น 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
Section titled โCreate a Virtual EnvironmentโNavigate to your project directory and run:
python -m venv myenv
โ
If successful, it will create a folder named myenv
.
Activate the Virtual Environment
Section titled โ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
Section titled โInstall Packages Inside Virtual Environmentโpip install requests numpy pandas
Verify installed packages:
Section titled โVerify installed packages:โpip list
To deactivate the virtual environment:
deactivate
๐น Step 5: Running a Python Script
Section titled โ๐น Step 5: Running a Python Scriptโ- Create a new Python file outside the virtual environment:
Terminal window echo "print('Hello, World!')" > hello.py - Run the script:
Terminal window python hello.py
โ Expected Output:
Hello, World!
๐น Step 6: Fixing โScript Not Found in PATHโ Warnings
Section titled โ๐น 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
Section titled โSolution: Add the Path to Environment Variablesโ- Open System Environment Variables (
sysdm.cpl
โ Advanced โ Environment Variables). - Find Path under System Variables and click Edit.
- Click New and add:
C:\Users\YourUsername\AppData\Roaming\Python\Python313\Scripts\
- Click OK, restart your terminal, and retry your commands.
๐ Conclusion
Section titled โ๐ 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! ๐ฏ