Forums

Can we have python-docx included in battery list

Hi, I've just got started with pythonanywhere[dot]com. And it has turned out to be awesome !
In this thread there is a suggestion to get python-docx and my python app requires python-docx. So how do I get it?

I tried the usual pip install but gives me permission denied error.

Here is the excerpt from error log

creating /usr/local/lib/python2.7/dist-packages/docx error: could not create '/usr/local/lib/python2.7/dist-packages/docx': Permission denied ---------------------------------------- Command "/usr/local/bin/python2.7 -c "import setuptools, tokenize;file='/tmp/pip-build-6H7KiQ/python-docx/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-EkDTRJ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6H7KiQ/python-docx

It seems the trick is to use

  --user

as in:

pip install python-docx --user

This link might be helpful to anyone landing into similar problem(s)

Cheers !

Thanks for posting the followup! That is indeed the trick -- here's a help page with more details.

I've installed 'docx' module: pip2.7 install --user python-docx but still I get an error:

<type 'exceptions.ImportError'> No module named docx.document
Version
web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python  Python 2.7.6: /usr/local/bin/uwsgi (prefix: /usr)
Traceback (most recent call last):
  File "/home/igorsavinkin/web2py/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/home/igorsavinkin/web2py/applications/welcome/controllers/default.py", line 11, in <module>
    from docx.document import Document
  File "/home/igorsavinkin/web2py/gluon/custom_import.py", line 95, in custom_importer
    return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named docx.document

why?

[edit by admin: formatting]

Did you reload your web site from the "Web" page after installing it?

I've reloaded and it works. Do I need to reload the app each time I install new library? What other cases do I need to reload the app?

Yes and any time you make a code change or a change to any of the configuration settings on the web app tab.