Python在virtualenv下找不到我的Flask脚本 [英] Python can't find my Flask script under virtualenv

查看:663
本文介绍了Python在virtualenv下找不到我的Flask脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Flask构建一个简单的API服务器,使用这个 phonenumbers.py 验证和存储国际电话号码。我之前在virtualenv中安装了Flask和几个Flask扩展,并开始构建我的应用程序。到现在为止还挺好。但是使用自己的安装程序下载并安装电话号码.py后,我发现在virtualenv中运行的python不能再找到我的应用程序脚本!看着目录,它坐在那里,但python不再认识它。我唯一能想到的另外一个问题就是,在安装之后,我使用了一个外部文本编辑器(venv外)来编辑我的应用程序脚本并重新保存。



我做了什么错了?



我比较了我的环境变量virtualenv的内部和外部。他们是相同的,除了以下3添加:

  VIRTUAL_ENV = /用户/ tokrum / callcenter / venv 

PATH = / Users / tokrum / callcenter / venv / bin#(被添加到我的$ PATH的开头,但其余的已存在的PATH和以前一样...)

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

callcenter-v0-1.py 。它位于名为 / callcenter / 的目录中,电话号码为7.0.1 ,venv文件夹位于我目录结构的同一级别。



感谢您提供的任何信息。 解决方案

使用

  $ pip install Flask-Script 


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.

解决方案

Install Flask_script in your virtual env using

$pip install Flask-Script

这篇关于Python在virtualenv下找不到我的Flask脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆