0

I have tried every command line installation possible in an attempt to install flask. I have followed the instructions from http://flask.pocoo.org/docs/installation/

After sudo easy_install virtualenv:

Searching for virtualenv
Best match: virtualenv 1.11.6
Adding virtualenv 1.11.6 to easy-install.pth file
Installing virtualenv script to /usr/local/bin
Installing virtualenv-2.7 script to /usr/local/bin

Using /usr/local/lib/python2.7/dist-packages
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

after pip-install flask:

Requirement already satisfied (use --upgrade to upgrade): flask in ./python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in ./python2.7/dist-packages (from Jinja2>=2.4->flask)
Cleaning up...

However after . venv/bin/activate:

bash: venv/bin/activate: No such file or directory

I do know how to navigate around the terminal and create directories. I am uncertain how to process this command and/or activate virtualenv. I cannot find this directory or perhaps the sudo/pip commands were intended for a directory not defaulted on my drive?

I try and run a python script using flask, and of course:

Traceback (most recent call last):
  File "testingflask.py", line 1, in <module>
    from flask import Flask
ImportError: No module named flask

Here is the script: testingflask.py

from flask import flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

I have tried apt-get install python-flask as well

1
  • 1
    Activate your venv first, then use pip. Or explicitly use the bin/pip in the virtual env directory. You installed Flask in globally, but by default a virtual env ignores the global packages. Commented Jul 9, 2014 at 15:08

3 Answers 3

1

Did you did the

$ mkdir myproject
$ cd myproject
$ virtualenv venv

step? (Apparently not)

In any case you should do the pip install Flask after activating the virutualenv. Else it get installed in you base python install.

Also take care, python is case sensitive:

from flask import Flask
app = Flask(__name__)
Sign up to request clarification or add additional context in comments.

1 Comment

Remember you need to activate the virtual environment with . venv/bin/activate. This has to be done each time you open a new shell.
0

Did you run virtualenv venv ? I mean do you have a venv folder in your project? I guess you missed that step!

  1. $ sudo easy_install virtualenv or sudo easy_install virtualenv
  2. $ mkdir myproject
  3. $ cd myproject
  4. virtualenv venv

I you follow those steps you should have a venv directory in myproject and the command $ . venv/bin/activate will work

Comments

0

One more thing to try

  • know your python path where site-packages are stored
  • download the flask module and extract it
  • copy the extracted folder and paste it into your python packages directory(mostly site- packages/dist-packages for me :/usr/lib/python2.7/dist-packages) [remember root only can do this]
  • open your python shell
  • and check "import flask"

know the location of your library files:

In [1]: import sys

In [2]: sys.path
Out[2]: 
['',
 '/usr/bin',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
 '/usr/lib/python2.7/dist-packages/IPython/extensions']

2 Comments

I do have flask install in this path above, but whenever I move around and create a virualenv venv and then try to install flask via pip install flask I receive the following error bash: /home/phillipk/rampup/sql/venv/bin/easy_install: /home/phillipsk/rampup/webapp/sql/venv/bin/python: bad interpreter: No such file or directory and here are my contents of that path activate activate.csh activate.fish activate_this.py easy_install easy_install-2.7 pip pip2 pip2.7 python python2 python2.7 (venv)kup@kuprevicius:~/rampup/sql/venv/bin$ python
I think you can copy the flask modules and paste inside the venv lib packages directory and try it to run import flask in python shell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.