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 Build a Social Network with Flask Making Strong Users The User Model

How can I do this on my local computer, not using the workspace?

What must I download to do this?

Marcelo Marcon
Marcelo Marcon
2,893 Points

first install a virtualenv using pip for python 3 on ubuntu machine sudo apt install python3-pip, if you using other distro linux just use the package manager for it, like yum install, dnf install, apt install, pkg_add on windows machine, whem you install python will came with pip.

then on terminal upgrade pip package, with the command sudo pip3 install -U pip. on windows machine open your terminal like normal user, python -m pip install -U pip then you need to install virtualenv, that provide a jail, like a container for your environ, sudo pip install -U virtualenv, on windows machine "python -m pip install -U virtualenv" so now, u must to have the virtualenv command, create a folder where you want to start your project.. virtualenv -p python3 venv the command above will create a folder called venv, or named what you want, with your viirtual environ with python 3, now you must to use that virtual environ

on linux u will type source venv\bin\activate on windows will you type venv\Scripts\activate

that you can install the packages thats kennedy use on project pip install flask flask_wtf flask_login peewee, windows and linux is the same .. and you wont need the sudo anymore.

open your favorite editor and be happy, to exit from the virtualenv just type deactivate on windows venv\Script\deactivate.bat

"sorry i am from brazil my english is not so good :) good luck "

7 Answers

You probably want to check out the course Setting Up a Local Python Environment here on Treehouse, which explains how to use venv and pip as Kenneth mentions in the first video.

I currently use Atom, but I downloaded the teachers files. When I attempt to open them, nothing happens. I tried all possible ways of opening them.

Russ Fleharty
seal-mask
.a{fill-rule:evenodd;}techdegree
Russ Fleharty
Python Web Development Techdegree Student 10,815 Points

I have Atom too. Open it up and click on file. Command(O) on a mac and pick a folder that you've downloaded from the teachers notes. It should open it right up. Good luck.

Okay, it was because I forgot to unzip the file. Now, when I open the files with chrome, they don't show a page, just a bunch of code..

Russ Fleharty
seal-mask
.a{fill-rule:evenodd;}techdegree
Russ Fleharty
Python Web Development Techdegree Student 10,815 Points

So you've unzipped the file, next it should have a folder with all the files you need. When you open up Atom, click File\Open File and select the whole folder. You should be able to preview your html document in browser of your choice.

Hi Russ,

Just a quick note...maybe Trenton is trying to look at (or edit) the python (.py) files in the zip/download for this course.

Atom will do this also.

.

I prefer Sublime Text, because it allows python autocomplete using SubLimeJedi:

https://github.com/srusskih/SublimeJEDI

But I downloaded Atom just to try it out.

It kind of has the same look/feel as PyCharm..

After doing some research I find it also has a project that is working to integrate the Jedi python autocomplete as well:

https://atom.io/packages/autocomplete-jedi


I don't think Brackets really supports Python auto-completion all that much.

I think there was some issue with the WordHint extension:

http://stackoverflow.com/questions/27343289/troubles-with-python-autocomplete-in-brackets

https://github.com/adobe/brackets/issues/10105

I got turned off on Brackets when Adobe discontinued Edge Code:

https://creative.adobe.com/products/code

I'm also not happy with Adobe due to what happened with Fireworks (which I still use the Macromedia version of):

http://www.smashingmagazine.com/2013/12/19/present-future-adobe-fireworks/

Thanks for the info though!


[Edit1] The Atom editor seems kind of "bawky" (takes longer to open then Sublime).

Looked through the package manager --didn't seem to have as many packages/plugins as Sublime.

Atom is open source though (unlike Sublime)..maybe it will get better.

I'm also tracking Lime (another open source alternative to Sublime):

https://github.com/limetext/lime

Right now Atom seems to have the more aggressive development cycling,

but we'll see how it goes..


I've never found something that filled the "sweet spot" between text editor and full IDE.

I tried PyCharm because I've also used JetBrain's IntelliJ for java projects (had to write my own plugins though to get it to do what I wanted).

Since I'm on Windows, IronPython is also my choice for python integration with .Net components.

Oziel Perez
Oziel Perez
61,321 Points

In addition to Iain Simmons comment, there is much more to setting up an environment if you plan to deploy to a live server. There is this whole other thing you must do where you have to set up the server's configuration file to read python scripts. In apache http server, this is done by enabling the mod_wsgi module, adding some settings to run wsgi on a specific folder or as a process, setting up a wsgi script file to import your flask app, and setting up your files and directories exactly like they are in the workspaces. It was incredibly frustrating to figure it out since there is practically no documentation on how to do all this. I had to visit Django's website to see how they deploy their apps. Again, this is necessary if you are wanting to get serious with flask development, as you can't run the app on port 5000 forever. It must be done in port 80 with the above settings.