Skip to content

πŸ’Ž A quick start for web server development using python flask, django and fastapi.

License

Notifications You must be signed in to change notification settings

CrispenGari/python-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python Backend

This repository contains some examples of backend applications using:

  1. Flask
  2. Django
  3. Fast API

Creating a virtual environment

There are two ways of creating a virtual environment in python.

  1. creating a virtual environment from a already exists folder.
  • to create a virtual environment in the existing folder you first need to navigate to the folder that you wnt to create virtual environment by running the command:
cd myv
  • then you run the following command to create a virtual environment
virtualenv .

This just means create a virtual environment in the current directory.

  1. creating a virtual environment and naming it.
  • to create a virtual environment by name you run the following command:
virtualenv venv

Activating virtual environment

To activate virtual environment you have to run the activate.bat file that will be generated in virtual environment that you have created for example:

.\venv\Scripts\activate
# or
.\venv\Scripts\activate.bat

Activating the first virtual (myv) you will do it as follows:

.\Scripts\activate
# or
.\Scripts\activate.bat

Deactivating virtual environment

To deactivate virtual environment you have to run the deactivate.bat file that will be generated in virtual environment that you have created for example:

.\venv\Scripts\deactivate
# 1.
.\venv\Scripts\deactivate.bat

Activating the first virtual (myv) you will do it as follows:

.\Scripts\deactivate
# 1.
.\Scripts\deactivate.bat

I recommend to navigate to the project directory after creating a virtual environment before installing packages:

πŸ“ root
    πŸ“ venv

To install the packages after activating the virtual environment you just run the following command:

pip install <package_name>

# example

pip install numpy

Getting an error?

If you are getting a command error that says:

'virtualenv' is not recognized as an internal or external command,
operable program or batch file.

You could try to install virtualenv using pip as follows:

pip install virtualenv

Or

python -m pip install virtualenv