Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Jekabs Dambergs
Jekabs Dambergs
7,417 Points

Build a Social Network with Flask - building outside Workspace, on Visual Studio Code

I decided that it will be beneficial to try and build the task of "Build a Social Network with Flask" outside Workspace and use the Visual Studio code, that I've installed on my laptop (Windows).

As the task requires to install the following, not sure how to do that on Visual Studio: -pip install flask -pip install flask-login -pip install flask-bcrypt -pip install peewee

Can anyone help with this? Also want to know if it's enough to successfuly complete this task or do I need to set up something more.

Aaron Jorgensen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Aaron Jorgensen
Python Development Techdegree Graduate 13,658 Points

I use PyCharm on OSX, however, IDE's like VScode utilize system binaries and packages. So VSCode will look for an existing installation of python for example. Pip is a package manager for python so installing things with pip, will/should result in VSCode having access to it. Make sure you pay attention to which version of python you are installing/using such as python3/pip3 other python2/pip. And make sure that in VSCode the python PATH is set to the version folder you are intending to use. I obviously suggest python3 as python2 has been retired and deprecated recently.

you are advised to create a virtual environment to work within and install the required packages in there to avoid future conflicts it you have different versions of a package or don't want to keep them beyond this project. Also it is required to create a requirements.txt file and have it in your repository so those using/testing it can install all the same packages to ensure they are working in the same environment you setup during development.

my requirements.txt looks like this:

Flask==1.0.2
Flask-Bcrypt==0.7.1
Flask-Login==0.2.11
flask-peewee==3.0.3
Flask-WTF==0.14.3
Jinja2==2.11.1
lazy-object-proxy==1.4.3
regex==2020.4.4
requests==2.23.0
slugify==0.0.1
SQLAlchemy==1.3.16
sqlparse==0.3.1
urllib3==1.25.8
utils==1.0.1
wcwidth==0.1.9
Werkzeug==1.0.1
wtf-peewee==3.0.0
WTForms==2.2.1

2 Answers

Jekabs Dambergs
Jekabs Dambergs
7,417 Points

Thanks for the reply, Aaron! Do you have PyCharm pro? As I see that their plans include the frameworks only in pro version.

Nevertheless, I'm using Python 3. I had it installed within VSCode. But I didn't get the pip packages to work? Also why do I need the requirements.txt?

Aaron Jorgensen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Aaron Jorgensen
Python Development Techdegree Graduate 13,658 Points

Good morning, I have the pro version for my main computer and the community on my laptop. The community version has a lot of features still and is great. The requirements.txt is a requirement of the flask journal project. It’s used to recreate the environment you used to build the project so they can cleanly emulate it. In addition, it is a good habit for you to include in your projects moving forward anyway. Both for yourself and also if you ever plan to host it on GitHub or have anyone else use your code.

Aaron Jorgensen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Aaron Jorgensen
Python Development Techdegree Graduate 13,658 Points

I’m not as familiar with windows but check the location of the python3 version on your machine and than check where your pip in installing packages. You may not have them in PATH

Jekabs Dambergs
Jekabs Dambergs
7,417 Points

Thanks Aaron for the suggestion.