I want to try using Flask with Python3. I've got Python 3.4 on Ubuntu 14.04, which supposedly ships with pip included. So I tried
pip3 install flask
this ends in:
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_kramer65/flask/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-i98xjzea-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_kramer65/flask
Storing debug log for failure in /tmp/tmpqc3b2nu5
So I tried importing it, but to no avail:
kramer65@vps1:~/cxs$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'flask'
I can of course download it and install using sudo python3 setup.py install
it that way, but I would rather do it "the standard way" so that things are easily and more standard to setup on production machines.
Does anybody know how I can import Flask with Python3 and pip? All tips are welcome!
Error log is available in http://pastebin.com/hd6LyVFP
You seem to have a permission issue. From the log you pasted to pastebin:
error: could not create '/usr/local/lib/python3.4/dist-packages/flask': Permission denied
This is because pip
will attempt to install the package globally unless you specify a certain installation location. If you want to install this globally you must use sudo
or install as a user with privileges.
Try the following:
sudo pip3 install flask
Or specify to a certain dir:
pip install -t <path> flask
However, with the latter method you will have to always inject the path to sys.modules
so I suggest you just use sudo
if you can.
Or even more preferrably, use virtualenv
. Virtualenv allows you to very easily package your application for production because you can install only the packages you need and you've thus got automatic package isolation. Generating a requirements.txt
is then as simple as pip freeze > requirements.txt
. Remeber that if you end using a virtualenv, you must not use sudo
to install packages as they will then be installed outside the virtualenv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With