ImportError while using py.exe instead of python.exe · Issue #979 · pypa/virtualenv (original) (raw)
(venv) PS C:\Users\wdhwg001\study> py hello.py
Traceback (most recent call last):
File "hello.py", line 5, in <module>
from flask import Flask
ImportError: No module named 'flask'
(venv) PS C:\Users\wdhwg001\study> py -m pip show flask
Name: Flask
Version: 0.11.1
Summary: A microframework based on Werkzeug, Jinja2 and good intentions
Home-page: http://github.com/pallets/flask/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: c:\users\wdhwg001\study\venv\lib\site-packages
Requires: click, Werkzeug, itsdangerous, Jinja2
(venv) PS C:\Users\wdhwg001\study> python hello.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
(venv) PS C:\Users\wdhwg001\study> py
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22🔞55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, os
>>> os.path.dirname(sys.executable)
'C:\\Users\\wdhwg001\\study\\venv\\Scripts'
>>> from flask import Flask
>>> app = Flask(__name__)
>>> @app.route('/')
... def hello_world():
... return 'hello world!'
...
>>> app.run()
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
>>>
I'm wondering how does this happened?
I only installed flask in a python3 virtualenv, and here is hello.py:
#! /usr/bin/env python3
""" A hello-world Flask server. """
from flask import Flask app = Flask(name)
@app.route('/') def hello_world(): """ Hello World! """ return 'Hello World!'
if name == 'main': app.run()