I have a small bar register program written in Python, Flask and Javascript that I am launching to Heroku.
I have made a virtual environment. Pip.ini file is already set to only download packages only to active virtual environments. I'm using VS Code. As you can see in the picture, I've downloaded some packages to my virtual environment's site-packages folder, and they are showing as imported in VS Code when opening this .py file. In VS Code, I've already selected the Python interpreter in the virtual environment.
from datetime import datetime
from flask import Flask, render_template, request, jsonify
from flask_sqlalchemy import SQLAlchemy
import os
import psycopg2
import requests
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, Date, ForeignKey, Float, MetaData
from sqlalchemy.orm import sessionmaker
import time
from decouple import config
I've already checked sys.path, and placed the path to my site-packages there. I've checked the pip executable in the command line, and it is the same pip in the virtual environment. The packages are showing in green in VS Code, meaning that VS Code sees the package there, in the site-packages folder, which they are definitely in.
However, whenever I run the program, I continue to get this message.
Traceback (most recent call last):
File "C:\Users\ninja\Desktop\BarRegister\barregister\BarRegister.py", line 3, in <module>
from flask import Flask, render_template, request, jsonify
ModuleNotFoundError: No module named 'flask'
If I activate the virtualenv in the command line and run the .py file from there, I get this error:
(barregister) C:\Users\ninja\Desktop\BarRegister\barregister>python BarRegister.py
Traceback (most recent call last):
File "C:\Users\ninja\Desktop\BarRegister\barregister\BarRegister.py", line 15, in <module>
databaseconn = config('DATABASE_URL')
File "C:\Users\ninja\Desktop\BarRegister\barregister\lib\site-packages\decouple.py", line 243, in __call__
return self.config(*args, **kwargs)
File "C:\Users\ninja\Desktop\BarRegister\barregister\lib\site-packages\decouple.py", line 105, in __call__
return self.get(*args, **kwargs)
File "C:\Users\ninja\Desktop\BarRegister\barregister\lib\site-packages\decouple.py", line 90, in get
raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: DATABASE_URL not found. Declare it as envvar or define a default value.
The error only goes away if I install the packages in the site-packages folder of the Python interpreter that made the virtualenv. I've already looked at other posts about this, and many people are either mentioning folder and files or configurations I do not have or what they've suggested still has not fixed this unfortunately.
Any info I am missing for this issue I will provide.