Two Good Habits in Coding: Virtual Environment and Github

Virtual Environments and GitHub are crucial tools in modern software development.

Virtual Environments allow developers to create isolated Python environments for each project, ensuring that dependencies and package versions don’t conflict across different projects. This isolation promotes consistency and reproducibility, making it easier to manage complex projects and collaborate with others.

On the other hand, GitHub, a web-based platform for version control using Git, facilitates collaborative coding, code sharing, and project management. It allows developers to track changes, revert to previous versions, create separate branches for features or experiments, and merge changes seamlessly. GitHub also serves as a portfolio for developers, showcasing their work and contributions to open-source projects. Together, these practices foster cleaner, more organized code, smoother collaboration, and more efficient development workflows.

Before detailing the steps, first, i want to upgrade python executable, the existing ones are

C:\Program Files\Python310\python.exe
C:\Users\ncarucci\AppData\Local\Microsoft\WindowsApps\python.exe

windows environment paths are

C:\Users\ncarucci\OneDrive – FactSet\Gitfolder\NQ100_Replica\venv\Scripts;
C:\Program Files (x86)\VMware\VMware Player\bin\;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;
C:\Program Files\Python310;
C:\Users\ncarucci\AppData\Local\Microsoft\WindowsApps;
C:\Users\ncarucci\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\ncarucci\AppData\Local\Programs\Git\cmd;
C:\Users\ncarucci\AppData\Roaming\factsetio\bin\;

Now I installed latest version 3.13.0 of python at C:\Users\ncarucci\OneDrive – FactSet\Programs\python, can continue next steps:

Coming to actual practice, there are some nuances and I would like to document the right process after trying.

First, go to github and create a new repo in the web page, create a new repo, and you can choose with or without readme.md, copy the znaixian/robot_2d (github.com). then go the folder where you want to store that git repo folder, in cmd, type “git clone https://github.com/znaixian/robot_2d.git”, then “cd robot_2d” because The general consensus is to create the virtual environment as a subdirectory within your project folder. This approach keeps all project-related files together and makes it easier to manage. This is an empty repo cloned, but it’s fine, it’s a clean and neat way to start an official project.

Then work on virtual environment creation:

python -m venv venv
>"C:\Users\ncarucci\OneDrive - FactSet\Programs\python" -m venv venv

to specify the latest python version custom installed in that path, type ….\Programs\python.exe -m venv venv

then activate the virtual environment by typing below or enter subfolder one by one to eventually activate

venv\Scripts\activate

don’t forget to create .gitignore and freeze commands to generate requirements.txt file.

After these steps, you can do the normal: creating files in local folder, do the git init, git add . and git commit -m “commit message”,

Attach the first vlog as a visual or video diary.

git clone repo name
python -m venv venv 
venv/scripts/activate 
echo # 3D Robot Assistant Simulation > README.md
git add .
git commit -m "commit message" 
git push origin main

created .gitignore file

(
echo # Virtual environment
echo venv/
echo env/
echo *.venv
echo .env
echo.
echo # Python cache files
echo pycache/
echo *.py[cod]
echo.
echo # Logs
echo *.log
echo.
echo # OS generated files
echo .DS_Store
echo Thumbs.db
echo.
echo # IDE specific files
echo .vscode/
echo .idea/
echo.
echo # Compiled Python files
echo *.pyc
echo.
echo # Distribution / packaging
echo .Python
echo build/
echo develop-eggs/
echo dist/
echo downloads/
echo eggs/
echo .eggs/
echo lib/
echo lib64/
echo parts/
echo sdist/
echo var/
echo wheels/
echo *.egg-info/
echo .installed.cfg
echo *.egg
) > .gitignore

type .gitignore

git rm -r –cached venv
git commit -m “Remove venv folder from version control”
git push

If work on branches:

# Create and switch to new branch
git checkout -b feature/new-feature

# Make your changes
# ... edit files ...

# Add and commit changes
git add .
git commit -m "Add new feature"

# Push branch to remote
git push -u origin feature/new-feature

a 10min video is recorded.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.