Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
flask_restful Unable to install with StaSh
-
Guys, I search the forum about this but could not find anything. But using StaSh to pip install flask-restful fails as it has to run a setup file. Not sure what the setup file is doing, but it appears that the installation and dependencies get installed ok.
To test I just used the 'hello'a world' starter script below. Anyway, it fails. It sees flask_restful module, but something is not connected correctly.
Is there a alternative way I can install this module with StaSh? I really don't like asking without doing my own research, but this is sort of a black pit for me. The answer could be staring me in the face and I probably would not see it.
Thanks in advance...btw, in this case I am looking for a solution for py3, but would be great to know if the same solution works under 2.7. If not does not matter so much, but plan to use one to run flask and the other to test query it.
from flask import Flask from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True)
-
flask-restful looks like a regular pure Python package, no idea why Stash is having trouble with the
setup.py
. You should be able to install the package by hand, by downloading the source code and moving the package intosite-packages
:$ wget "https://files.pythonhosted.org/packages/20/f1/14a62bba209ae189e5c5fa33d5e0b7a4b5969488fa71fd3b8b323860bfc8/Flask-RESTful-0.3.6.tar.gz" $ tar -xzf Flask-RESTful-0.3.6.tar.gz $ mv Flask-RESTful-0.3.6/flask_restful ~/Documents/site-packages/flask_restful
-
@dgelessus , thanks for helping out. But still no go. I pip removed flask-restful, then did the manual install using the above cmds you wrote. The one thing I noted, and I guess is normal is that the dependencies that first installed with flask-restful do not get uninstalled. I have add a pic below of what I am getting, I though this might be better than the trace back. The code should work, it is the example code from the flask-restful site, I also have had in running in PyCharm on the mac. Any further hints would be great.
-
OK, it's showing a syntax error in the Flask source code, which is strange. Can you check if you have a
flask
folder in any of yoursite-packages
folders, and delete it if there is one? Flask is already pre-installed in Pythonista, but Stashpip
probably installed it again and might have broken something by doing that. -
@dgelessus , I did have a flask folder in site-packages. I got rid of it and restarted Pythonista and got the below trace back.
I tried the exact same thing in the Pythonista 2 app. Exactly same error. Also, same error if I run it in the 3 app using py2.7Look I don't want to waste your time. It would be nice to get it running. But I can still use it by doing it on my laptop.
- Running on http://127.0.0.1:5000/
- Restarting with reloader
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/3533032E-E336-4C25-BBC4-112A6BF2AF75/Pythonista3/Documents/MyProjects/scratch/flask_restful_test.py", line 14, in <module>
app.run(debug=True)
File "/var/containers/Bundle/Application/2A23FD4D-8164-4F78-9144-DD77D005D434/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/flask/app.py", line 773, in run
run_simple(host, port, self, **options)
File "/private/var/mobile/Containers/Shared/AppGroup/3533032E-E336-4C25-BBC4-112A6BF2AF75/Pythonista3/Documents/site-packages/werkzeug/serving.py", line 708, in run_simple
run_with_reloader(inner, extra_files, reloader_interval)
File "/private/var/mobile/Containers/Shared/AppGroup/3533032E-E336-4C25-BBC4-112A6BF2AF75/Pythonista3/Documents/site-packages/werkzeug/serving.py", line 617, in run_with_reloader
sys.exit(restart_with_reloader())
File "/private/var/mobile/Containers/Shared/AppGroup/3533032E-E336-4C25-BBC4-112A6BF2AF75/Pythonista3/Documents/site-packages/werkzeug/serving.py", line 601, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ)
File "/var/containers/Bundle/Application/2A23FD4D-8164-4F78-9144-DD77D005D434/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 268, in call
with Popen(*popenargs, **kwargs) as p:
File "/var/containers/Bundle/Application/2A23FD4D-8164-4F78-9144-DD77D005D434/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 708, in init
restore_signals, start_new_session)
File "/var/containers/Bundle/Application/2A23FD4D-8164-4F78-9144-DD77D005D434/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 1261, in _execute_child
restore_signals, start_new_session, preexec_fn)
PermissionError: [Errno 1] Operation not permitted
-
@dgelessus , btw I copied the output when I installed it on Pythonista app 2.
[~/Documents]$ pip install flask-restful
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/20/f1/14a62bba209ae189e5c5fa33d5e0b7a4b5969488fa71fd3b8b323860bfc8/Flask-RESTful-0.3.6.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//Flask-RESTful-0.3.6.tar.gz (103092 bytes)
103092 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Package installed: Flask-RESTful
Installing dependency: aniso8601[('>=', '0.82')]
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/61/f3/74a5a8affb192863f5f6aa3dfb0059a97442ff683d44fcc842b509758129/aniso8601-1.2.1.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//aniso8601-1.2.1.tar.gz (62369 bytes)
62369 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Package installed: aniso8601
Installing dependency: python-dateutil
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/54/bb/f1db86504f7a49e1d9b9301531181b00a1c7325dc85a29160ee3eaa73a54/python-dateutil-2.6.1.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//python-dateutil-2.6.1.tar.gz (241428 bytes)
241428 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Package installed: python-dateutil
Dependency available in Pythonista bundle : six
Installing dependency: Flask[('>=', '0.8')]
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/49/0a/fe5021b35436202d3d4225a766f3bdc7fb51521ad89e73c5162db36cdbc7/Flask-0.9.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//Flask-0.9.tar.gz (481982 bytes)
481982 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Package installed: Flask
Installing dependency: Werkzeug[('>=', '0.7')]
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/63/69/5702e5eb897d1a144001e21d676676bcb87b88c0862f947509ea95ea54fc/Werkzeug-0.9.6.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//Werkzeug-0.9.6.tar.gz (1128428 bytes)
1128428 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Package installed: Werkzeug
Installing dependency: Jinja2[('>=', '2.4')]
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/90/61/f820ff0076a2599dd39406dcb858ecb239438c02ce706c8e91131ab9c7f1/Jinja2-2.9.6.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20091A2E-FA21-4354-B157-CF8CBF605DC4/tmp//Jinja2-2.9.6.tar.gz (437659 bytes)
437659 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
TypeError('string indices must be integers, not str',)
Failed to run setup.py
Fall back to directory guessing ...
Error: Cannot locate packages. Manual installation required. -
Ah, it's not possible to use Flask's debug mode in Pythonista. Among other things, debug mode enables automatic reloading of the server when you change the source code, which requires the ability to start new Python processes, which isn't possible in Pythonista.
-
@dgelessus , thanks so much. Took the debug out and it works. But I am almost sure that it used to work. Maybe I am wrong.
But really, thank you. It's great it's working.
I finally got PythonAnywhere working today the way I want. I just had to watch a video :).
here I just have the basic todo list example from the docs working. But I finally figured out how to install and configure a virtualenv there.