Starting Your Python Project
Last updated
Last updated
0. Set Up Your Visual Studio Code
Learn the Terminal
TerminalTutor is a fanatastic tool to learn how to use the terminal.
Create a Github Repository and Clone it onto your drive
Git + Github is a good way to do version control so that you can go back to your previous states of your program without worrying about CTRL+Z
.
Log in to GitHub:
Go to GitHub and log in with your credentials.
Create a New Repository:
Click on the + icon in the top right corner and select New repository.
Repository Details:
Enter a repository name.
Optionally, add a description.
Select Public or Private under the repository visibility options.
Optionally, you can initialize the repository with a README, .gitignore, or a license.
Create Repository:
Click on the Create repository button.
Copy Repository URL:
On your repository page, click on the Code button.
Copy the URL provided (HTTPS).
Open Terminal/Command Prompt:
Open your terminal (Mac/Linux) or Command Prompt (Windows).
Navigate to Desired Directory:
Use the cd
command to navigate to the directory where you want to clone the repository.
Clone the Repository:
Use the git clone
command followed by the repository URL you copied.
Navigate into the Cloned Repository:
Change into the repository directory:
(Windows Only) Enable your computer to run scripts
Open PowerShell as Administrator:
Press Win + X
and select Windows PowerShell (Admin) or Windows Terminal (Admin) if you're using Windows Terminal.
Check Current Execution Policy:
In the PowerShell window, type the following command and press Enter:
This will show you the current execution policy. By default, it might be set to Restricted
.
Set Execution Policy:
To allow scripts to run, you can set the execution policy to RemoteSigned
Set up a Python Virtual Environment in your repository
The reason we want to have a Python Virtual Environment is to isolate our project for the following benefits:
Isolated Projects will have their own modules and libraries installed
Example: If your project is using an earlier version of Streamlit and your computer has a newer version of Streamlit, your project will not be affected by the local machine's version differences
Easier to create a list of libraries and modules your project is dependent on
Create a Virtual Environment:
This command creates a directory named myenv
containing a new Python environment.
Activate the Virtual Environment:
On Windows:
On macOS/Linux:
To Deactivate to venv
you can simply run deactivate
on your terminal
4a. Create a .gitignore
file
With our virtual environment set up, please create a new file within the main folder of your repository not inside myenv
The file should be called .gitignore
This file will tell git to ignore the list of folders and files we write within it
Contents to be written in .gitignore
By having this in your .gitignore
, git will automatically not track changes in your virtual environment to upload to GitHub.
With your virtual environment activated, Install your libraries/dependencies/modules
Windows:
macOS:
Now your project should have all it requires.
Upload any changes to your GitHub