To run the codes in this project, we created a .toml file, so creating virtual environments and installing dependencies is possible with the Poetry Python package. This document outlines the steps taken to set up and troubleshoot Poetry with Python, focusing on resolving issues related to virtual environments and Python version compatibility.
Ensure that Python 3.9 is correctly installed and accessible:
C:\Users\YourUsername\AppData\Local\Programs\Python\Python39-32\python.exe --version
This should output Python 3.9.x. If it fails, reinstall Python 3.9.
-
Remove Existing Virtual Environment
poetry env remove python
-
Set Python Version for Poetry
poetry env use C:\Users\YourUsername\AppData\Local\Programs\Python\Python39-32\python.exe
-
Reinstall Dependencies
If using
poetry install
is not preferred, skip this step.
-
Create Virtual Environment
C:\Users\YourUsername\AppData\Local\Programs\Python\Python39-32\python.exe -m venv myenv
-
Activate Virtual Environment
.\myenv\Scripts\activate
-
Install Poetry in the Virtual Environment
pip install poetry
-
Initialize Poetry
Navigate to your project directory and run:
poetry init
-
Add Dependencies
Manually add dependencies as needed:
poetry add <dependency>
-
Add Jupyter Notebook
poetry add jupyter
-
Run Jupyter Notebook
poetry run jupyter notebook
-
Python Executable Issues
Verify that the correct Python executable is being used and is functional.
-
Virtual Environment Errors
Ensure that old or conflicting virtual environments are removed.
-
Configuration Issues
Check and reset Poetry’s configuration:
poetry config --list poetry config --unset virtualenvs.prefer-active-python
-
Permissions Errors
Run PowerShell or Command Prompt as an Administrator if facing permission issues.
- Verify Python Installation.
- Reconfigure Poetry and Set Python Version.
- Manually Create and Manage Virtual Environment if needed.
- Run Jupyter Notebook and troubleshoot common issues.
For further assistance, refer to Poetry and Python documentation or seek help from relevant forums.
Replace YourUsername
with your actual Windows username in the file.