Skip to content

Instantly share code, notes, and snippets.

@xprilion
Last active December 13, 2019 23:20
Show Gist options
  • Save xprilion/d75b3fcb090d60ccda674eef7cf65453 to your computer and use it in GitHub Desktop.
Save xprilion/d75b3fcb090d60ccda674eef7cf65453 to your computer and use it in GitHub Desktop.

Python Version

3.8

Date of Setup

13 Dec, 2019

PIP version

19.2.3

Install Virtualenv

pip install virtualenv

Create env

virtualenv venv

Activate env

venv\Scripts\activate

Install requirements

pip install -r requirements.txt

Found error 1

ERROR: Could not find a version that satisfies the requirement pypiwin32==220; sys_platform == "win32" and python_version >= "3.6" (from docker==3.4.0->-r requirements.txt (line 14)) (from versions: 219, 223)
ERROR: No matching distribution found for pypiwin32==220; sys_platform == "win32" and python_version >= "3.6" (from docker==3.4.0->-r requirements.txt (line 14))

Solution

Remove Line 14 to 17 from requirements.txt

docker==3.4.0
docker-compose==1.21.2
docker-pycreds==0.3.0
dockerpty==0.4.1

Set Environment variables

Created .env file. Added the content below -

set "FLASK_ENVIRONMENT_CONFIG=dev"
set "SECRET_KEY=nice_secret"
set "SECURITY_PASSWORD_SALT=something_salty"
set "MAIL_DEFAULT_SENDER=username"
set "MAIL_SERVER=smtp.gmail.com"
set "APP_MAIL_USERNAME=username@gmail.com"
set "APP_MAIL_PASSWORD=pass"

Run app

python run.py

Found Error 2

AttributeError: module 'time' has no attribute 'clock'

Solution

Mentioned here in the Python Docs

The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requirements, to have well-defined behavior. (Contributed by Matthias Bussonnier in bpo-36895.)
  1. Changed mentorship-backend\venv\lib\site-packages\sqlalchemy\util\compat.py", line 172:
  • time_func = time.clock
    
  • time_func = time.perf_counter
    
  1. Changed mentorship-backend\venv\lib\site-packages\flask_sqlalchemy_init_.py", line 39:
  • _timer = time.clock
    
  • _timer = time.perf_counter
    

It runs! 🎉

Try User Registration

Found Error 3

500 Internal server error with User created successfully. Suspect .env file not getting read.

Solution:

Try No. 1 - Change .env file

Changed .env file to -

FLASK_ENVIRONMENT_CONFIG=dev
SECRET_KEY=nice_secret
SECURITY_PASSWORD_SALT=something_salty
MAIL_DEFAULT_SENDER=username
MAIL_SERVER=smtp.gmail.com
APP_MAIL_USERNAME=username@gmail.com
APP_MAIL_PASSWORD=password

Didn't Work!

Try No. 2 - Set variables in the cmd

Copied the entire previous .env file into terminal, this works. Should add the following lines for making this permanent -

In File: mentorship-backend/venv/Scripts/activate Content:

set "FLASK_ENVIRONMENT_CONFIG=dev"
set "SECRET_KEY=nice_secret"
set "SECURITY_PASSWORD_SALT=something_salty"
set "MAIL_DEFAULT_SENDER=username"
set "MAIL_SERVER=smtp.gmail.com"
set "APP_MAIL_USERNAME=username@gmail.com"
set "APP_MAIL_PASSWORD=password"

This works. Life is good!

Run tests

187 tests passed.

Goodnight!

(Guess who discovered he put his password in the details above. Sigh. Ctrl+C to Ctrl+V)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment