sphinx-quickstart fails - python

I'm really having trouble getting to the first rung of the Sphinx tutorial ladder.
I need to implement Sphinx for work projects. We are starting fresh with a new code-base (Django) for a large project.
I've been tasked with setting up our new code-base (automated unit tests, documentation, etc). I've used doxygen in the past (mostly for C++ and a bit for Python). I've read a lot of sources saying Sphinx is the best for Python and I'd like to give it a try.
The problem is that I can't even seem to get through the first step of the tutorial - sphinx-quickstart.
I am able to tab-complete the command so I assume it's installed correctly. (maybe not?)
Here is the error I get:
File "/usr/local/bin/sphinx-quickstart", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: docutils>=0.7
I've tried to find some online info related to this problem but I haven't been able to find anything useful.
Any suggestions?

Looks like you are missing docutils, or you have an older version;
pkg_resources.DistributionNotFound: docutils>=0.7
Are you sure it's installed?

Try:
pip install --force-reinstall sphinx
It looks like the Sphinx package was not correctly installer or, more correctly, it's dependencies are not currently installed. If you do not have super-user privilege, then find an administrator to install or use virtualenv instead.
I highly recommend using virtualenv whenever possible since it does not touch the stuff in /usr/local or any of the Python .../site-packages directories. I will warn you that it is rather addictive :-)

Related

Could not find module \atari_py\ale_interface\ale_c.dll (or one of its dependencies)

I'm trying to work with the openai gym module but I get this error:
>>> import atari_py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\__init__.py", line 1, in <module>
from .ale_python_interface import *
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\ale_python_interface.py", line 17, in <module>
ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__),
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\ale_interface\ale_c.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I don't have an ale_c.dll and tried finding solutions but nothing worked.
I followed the solution here https://github.com/openai/gym/issues/1726 but when trying to import atari_py it comes up with the same error. I don't see why the __init__ would search for something that didn't come with the module either. There were other StackOverflow questions that I looked at but they also yielded no results. The only solution I can think of is to get a copy of ale_c.dll but I don't know how I would get it.
I was facing the same error. Fortunately, I was able to find one workaround. Follow this steps and you should be good to go.
Download ale_c.dll from here.
Copy it in C:\Users\Deep Raval\AppData\Local\Programs\Python\Python38\Lib\site-packages\atari_py\ale_interface (Your path can be different).
Try to download arari-py package from conda
conda install -c conda-forge atari_py
this will fix your problem even if you are using Python > 3.7
For anybody else in the future, my problem was that I got the same error but I already had the ale_c.dll file in the right folder.
I followed a solution on this link --> https://github.com/openai/gym/issues/1726
I have tried to make it work with python 3.8 and 3.9 on Windows 10. Installing Python 3.7 and using it as the Python Interpreter on PyCharm resolved the issue. I have searched for the missing file while having 3.8 + version of Python and it did not exist at all. Atari-py is supported only for Python 3.7 (https://github.com/openai/atari-py) so having a higher version of that would not work. It is a bad idea to download files from unlicensed places so I advise you to install the supported version of Python (3.5, 3.6, and 3.7). Even though gym can work on 3.9 the atari version will not.
Just an update because gym 0.21.0 came out which supports ale-py and no longer uses atari-py (so any game marked v0 - v4 will no longer work if you use gym 0.21.0 and ale-py (which is supposed to come with gym). Make sure when you install your libraries that they are actually compatible.
Link to new version of gym https://brosa.ca/blog/ale-release-v0.7. When running v5 I do manage to render the game but I cannot find the other supported games. If you use gym 0.21.0 you will not need atari-py (atari_py).
From the example:
import gym
env = gym.make('ALE/Breakout-v5',
obs_type='rgb', # ram | rgb | grayscale
frameskip=5, # frame skip
mode=0, # game mode, see Machado et al. 2018
difficulty=0, # game difficulty, see Machado et al. 2018
repeat_action_probability=0.25, # Sticky action probability
full_action_space=True, # Use all actions
render_mode=None # None | human | rgb_array
)
it does actually run but the game is broken even in older versions of gym.
What I managed to get working after trying various python, gym and atari-py versions is:
I would suggest to the downloade the wheel file for you Windows and Python version from here: https://pypi.org/simple/atari-py/
and then execute pip install on this file like:
pip install atari_py-0.2.9-cp39-cp39-win_amd64.whl
This one helped for me (solution from github seems much much better, but it was not working for me - maybe because of venv? ) - for me it's a more safe solution than downloading a .dll from google drive.
This is a problem that you may face when using Windows.
Uninstall and reinstall atari using:
pip install -f https://github.com/Kojoley/atari-py/releases atari_py

Requiring PsychoPy fails readthedocs build due to memory consumption

I have a project (https://github.com/jfkominsky/PyHab) which is essentially an extension of PsychoPy (http://psychopy.org/). I want to use Sphinx and ReadTheDocs for code documentation. I use the autoclass features from Sphinx for my documentation and have most of it in the code itself, which works great on local builds. On ReadTheDocs, this means that I needed to add a requirements file with psychopy as a requirement. This causes the build to fail in the following way:
/home/docs/checkouts/readthedocs.org/user_builds/pyhab/envs/latest/bin/pip install --exists-action=w --cache-dir /home/docs/checkouts/readthedocs.org/user_builds/pyhab/.cache/pip -rdocs/requirements.txt
Command killed due to excessive memory consumption
I'm very amateur at this. Is there a way to use a setup.py virtual environment to get psychopy to work? Is readthedocs just being too stingy with memory? I've noticed psychopy itself has some issues with RTD builds right now, unsure if that's related...
EDIT: I should add, I was using Cpython2 as my environment in RTD. When I use CPython3 instead I get a different failure:
I tried again with Py3 and got a different error:
ERROR: failed building wxWidgets
Traceback (most recent call last):
File "build.py", line 1321, in cmd_build_wx
wxbuild.main(wxDir(), build_options)
File "/tmp/pip-build-7a1lqn7v/wxPython/buildtools/build_wxwidgets.py", line 374, in main
"Error running configure")
File "/tmp/pip-build-7a1lqn7v/wxPython/buildtools/build_wxwidgets.py", line 85, in exitIfError
raise builder.BuildError(msg)
buildtools.builder.BuildError: Error running configure
Finished command: build_wx (0m10.842s)
Finished command: build (0m10.842s)
Command '"/home/docs/checkouts/readthedocs.org/user_builds/pyhab/envs/latest/bin/python" -u build.py build' failed with exit code 1.
I have devised a solution, at least for CPython2.x. The long and short of it, which RTD needs to advertise MUCH better, is that you can slip a bunch of 'mocks' into conf.py in order to bypass modules you don't want to actually import when compiling your docs. You need mock in your requirements file in 2.7 (presumably unittest.mock in 3.x)
The idea came from here: http://blog.rtwilson.com/how-to-make-your-sphinx-documentation-compile-with-readthedocs-when-youre-using-numpy-and-scipy/
Which connects back to this in the FAQ: http://read-the-docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
I realized that you could create mock modules for literally anything, and if you use MagicMock you can add attributes to them as needed. It took me several tries to get all the right mock modules (mostly because the RTD environment is hard to emulate locally and it would only show you the first module it failed to import in the error message), but eventually, I was able to convince RTD that it had everything it needed without exceeding its memory limits.
This solution is not psychopy-specific. This will work for anything that you have trouble pip installing on RTD.

Latex rendering not working in Inkscape 0.92.2?

I have used Inkscape and Latex extensively before. However I had to recently reinstall OS and all softwares I need on my computer. It is Linux Mint 18.3 Cinnamon now.
I am unable to render simple latex formula in Inkscape 0.92.2. The Ghostscript version I have is 9.18, and Texlive 2017 full installation. The error that I am getting is linked below. I will appreciate any help on this. Thank you!
Inkscape_Latex_Error
" Traceback (most recent call last):
File "eqtexsvg.py", line 160, in <module>
e.affect()
File "/usr/share/inkscape/extensions/inkex.py", line 285, in affect
self.output()
File "/usr/share/inkscape/extensions/inkex.py", line 272, in output
self.document.write(sys.stdout)
File "src/lxml/etree.pyx", line 2050, in lxml.etree._ElementTree.write
(src/lxml/etree.c:67059)
File "src/lxml/serializer.pxi", line 731, in lxml.etree._tofilelike
(src/lxml/etree.c:141721)
File "src/lxml/etree.pyx", line 326, in
lxml.etree._ExceptionContext._raise_if_stored (src/lxml/etree.c:13244)
File "src/lxml/serializer.pxi", line 648, in
lxml.etree._FilelikeWriter.write (src/lxml/etree.c:140348)
TypeError: write() argument must be str, not bytes"
Let me give you the solution first that worked for me. I was having the same problem with Inkscape 0.92.2. If you are not very specific about using the latest version of Inkscape then just uninstall 0.92.2 and install version 0.91.7. It will solve your problem. I am using Ubuntu 16.04. In the software center both these versions are available. But initially, I also chose 0.92.2 and started having the same problem. Then I uninstalled it and installed the older version. Latex rendering is working perfectly now. Just one thing, before doing anything else, check whether you have "pstoedit" installed or not. If not, do it first.
I understand why 0.92.2 is not working on Ubuntu 16.04 or for your system. Inskscape uses the python script "eqtexsvg.py" to convert tex equations to svg format. This process obviously require the python script to find the path of latex command. When you install 0.91.7 you will see Inkscape gets installed in /usr/share directory. But 0.92.2 uses /home/user/snap directory. Hence, the .inx part of the extension can neither find latex nor dvips. I think the problem with 0.92.2 can be solved as well just by mentioning the full path of latex and dvips in the .inx file. I was too lazy to do that. Anyway, 0.91.7 is pretty good enough at this moment for me. I may try the other solution later.

py2app SyntaxError when running with python3.3

I have written a sudoku solver using especially, but not only, tkinter and multiprocessing. I want to make it a standalone app, which I'm using py2app for.
I've run py2applet-3.3 --make-setup sudoku_app.py (that is what it's called when installed through macports), and it succeeded at that. However when building with python3.3 (python3.3 setup.py py2app), it returns a SyntaxError with an almost endless stack trace that ends like this:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/modulegraph/modulegraph.py", line 954, in load_module
co = compile(contents, pathname, 'exec', 0, True)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sympy/mpmath/libmp/exec_py2.py", line 2
exec string in globals, locals
^
SyntaxError: invalid syntax
When running the same setup file with python2.7, it does succeed to build, but there's a bunch of errors when trying to run the created .app. I've written my code in python3, although trying to maintain python2 compatibility through various try ... except - blocks and from future imports. At some point though, it got too complicated and I decided to just go with python3.
Why does py2app not work with python3 there?
Your application doesn’t work with py2app (yet) because I didn’t consider the way you do py3k support. In particular, modulegraph assumes that all modules in the dependency graph contain valid python code for the current python version.
Could you file a bug at my bitbucket page (https://bitbucket.org/ronaldoussoren/py2app) to ensure that I don’t forget to fix this?

Install Plone egg as a Python module on Windows

I have a Plone site (Plone version 3.1.2) that I need to install a product called GrufSpaces on - (http://plone.org/products/grufspaces). However, it is a production site and so I can't easily take it down to upgrade Plone to 3.2+ in order to use buildout; using buildout would allow me to easily add Grufspaces (collective.groupspace.roles etc) as a Product.
I have downloaded the egg files separately (roles, workflow, mail, content) and placed them in a directory structure like so:
collective/
__init__.py
groupspace/
__init__.py
content/...
roles/...
workflow/…
mail/...
What I thought I could do is add this "collective" folder to [plone directory]/Zope/lib/python as a Python module. The idea being once its added I can restart Plone/Zope and it will automatically pick it up and make it available within Plone as a Python Module. Unfortunately it has not worked as of yet.
If I am going about this the wrong way I welcome any suggestion to try this a different way.
If you are trying to install GrufSpaces 2.0 then you should consider upgrading to Plone 3.3 (see the install requirements)
Placing the collective.* packages to [plone directory]/Zope/lib/python should work. But these packages are not compatible with Plone 3.1. Here is the example of ImportError that I get when using collective.groupspace.roles with Plone 3.1:
File "/home/andrey/tmp/zope/instance/lib/python/collective/groupspace/roles/browser/roles.py", line 23, in ?
from plone.app.workflow import PloneMessageFactory as _
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/andrey/tmp/zope/instance/etc/site.zcml", line 15.2-15.23
ZopeXMLConfigurationError: File "/home/andrey/tmp/zope/instance/Products/GrufSpaces/configure.zcml", line 17.4-17.53
ZopeXMLConfigurationError: File "/home/andrey/tmp/zope/instance/lib/python/collective/groupspace/roles/configure.zcml", line 7.4-7.34
ZopeXMLConfigurationError: File "/home/andrey/tmp/zope/instance/lib/python/collective/groupspace/roles/browser/configure.zcml", line 5.4-10.10
ImportError: cannot import name PloneMessageFactory
Besides collective.* packages you have to download GrufSpaces product from SVN (download link at plone.org doesn't work for me) and place it in Products folder.
Did you check GrufSpaces' INSTALL.TXT? From there:
Unpack it into your Zope Products Folder
For Plone, the easiest way is probably to unpack it the top level products folder.
See also http://plone.org/documentation/kb/third-party-products/installing, section "Installing Zope 2-style Products Without Buildout".
No advice specific to GruffSpaces as I've never used it but it sounds like you may be under the mistaken impression that you need Plone 3.2+ for buildout. This is incorrect. Buildout works just fine with Plone 3.1.2. I've also done buildouts for Plone 2.5.5 and even one for Plone 2.1 (although this last one was a bit tricky because the required python for that version doesn't do buildout).
So if you prefer the buildout route, just do it. Although upgrading your Plone is probably still good advice.

Categories