0

I'm trying to build a simple API server using Flask that will validate and store international phone numbers using this phonenumbers.py. I previously installed Flask and several Flask extensions in a virtualenv, and started building my app. So far so good. But after downloading and installing phone numbers.py using its own installer, I found that python running inside virtualenv could no longer find my app script! Looking at the directory, it's sitting right there, but python does not recognize it any more. The only other wrinkle I can think of is that after doing the install, I used an external text editor (outside the venv) to edit my app script and re-save it.

What have I done wrong?

I compared my environment variables inside and outside virtualenv. They are the same except for the following 3 additions:

VIRTUAL_ENV=/Users/tokrum/callcenter/venv

PATH=/Users/tokrum/callcenter/venv/bin  # (was added to the beginning of my $PATH, but the rest of pre-existing PATH is as before….)

PS1=(venv)\h:\W \u\$

My app is called callcenter-v0-1.py. It lives in a directory called /callcenter/, along with the phone numbers-7.0.1 and venv folders at the same level of my directory structure.

Thanks for any light you can shed on this.

rnevius
  • 26,578
  • 10
  • 58
  • 86
Phoenix
  • 29
  • 3
  • 4

2 Answers2

1

Install Flask_script in your virtual env using

$pip install Flask-Script
ekad
  • 14,436
  • 26
  • 44
  • 46
-1

Make sure that you activated the virtualenv before you installed Flask and your other dependencies -

$ virtualenv env
$ source env/bin/activate
$ pip install flask

Then when you're done working, make sure to deactivate the environment -

$ deactivate

Finally, when you want to start working again, navigate to your project directory and reactivate the environment -

$ source env/bin/activate

At this point, I would just remove the virtualenv and start over.

Hope that helps!

Michael
  • 1,177
  • 4
  • 20
  • 71