Sphinx Extensions (numpydoc) - python

NOTE Added After: I finally got numpydoc working. It was also a python 2 problem. I ran 2to3 on it and now it seems to be working.
OK, I've spent an entire day trying to get any Sphinx extension to work and am now hoping someone could point out what I'm doing wrong. (Sorry this is a bit long, but maybe more info will help you quickly find the error of my ways).
Sphinx seems to be working as advertised, but I would like to use NumPy style documentation so thought I'd install numpydoc. In case it matters, I'm using Python 3.3 (winpython 64 bit on windows 7). I started with the directions here but got the error:
Extension error:
Could not import extension numpydoc (exception: cannot import name setup)
Googling that I found that some people got around it by using numpydoc.numpydoc No dice. I made sure everything possibly relevant was in my path (as well as added into sys.path in sphinx's conf.py file). I even tried copying numpydoc into sphinx's ext folder and changing the extension string accordingly, still no luck.
At this point I gave up on numpdoc and decided to try napoleon. Following the installation directions I just pip install sphinxcontrib-napoleon and then should be good to go. But alas, no, as napoleon seems to be in 2.x not 3 (though the egg says Sphinx-1.1.3-py3.3.egg-info and during installation it says it is installing sphinxcontrib_napoleon-0.2.1-py3.3-nspkg.pth. None-the-less, lots of python 2 code. I tried converting it with 2to3 but then I get a recursion too deep error.
So, I decide to see if I am capable of installing any extension to sphinx. I essentially at random pick findanything. Install it as requested and it also fails, this time because of a relpath error (ValueError: path is on mount 'C:', start on mount 'D:'). Which I guess means that it is unhappy that my python installation is on C but my code I'm trying to document (and where I'm trying to run sphinx) is on D (and that I'm running Windows).
So, did I just happen to pick 3 troubled extensions? Or, if not, what am I doing wrong and (more importantly) how can I do it right so that I get this working?
PS I'm completely new to Python so please don't assume that I'm not making an incredibly stupid and basic error.

Old thread, however...
If you are using Ubuntu 20+, don't install numpydoc via pip. Use
apt install python3-numpydoc
instead. Many of the sphinx packages need to be installed this way going forward.

Related

Python Requests: Where is Crypto.dll?

I am trying to use the Python requests module on Windows with Anaconda. After installing it with pip, attempting to import it fails because asn1crypto is required in the cryptography 2.2.2 module. After installing that with pip, it fails because the crypto library (that'd be crypto.dll on Windows) does not exist. Where the heck does this come from? The way asn1crypto uses it makes it seem like this is libcryptoXXX.dll, but I do not see any circumstance that it would be called crypto.dll. It looks like very old versions of pyOpenSSL (back when it was python-OpenSSL) came with crypto.so for Unix distributions, but I don't know where that came from and don't see any mention of a crypto.dll (and crypto.so was no longer distributed by the version of pyOpenSSL that requests says it requires). So what is this crypto.dll and where can I get it?
Setting expectations up front - all I've got to offer is a workaround and notes on my own experience.
I was faced with the same issue with Anaconda on Windows, and after going on a small adventure I simply removed asn1crypto from Anaconda. This raised an issue with a dependent package, so I removed that. 5 or 6 packages later I had a subset of Anaconda where Python code seems to successfully build and run.
My assessment is that this is an issue with Anaconda on Windows, specifically with asn1crypto (why do you expect and need "crypto.dll" on machines that don't have it, and offer no alternative?). I'd love to be wrong and for someone to tell me why.
My small adventure had me fruitlessly looking for the mysterious crypto library. I describe this below.
Looking for the "crypto.dll", I came across some questionable leads before landing here, which suggested I could pick up "libcrypto.dll" as part of an older version of OpenSSH for Windows. Not quite what I was looking for, but worth a try. Didn't work. Tried the 32 bit version (in path via system32) and the 64 bit version (in path via SysWOW64) with no luck. Tried the new and renamed to "libeay32.dll" version from a later release of OpenSSH on Windows. Didn't work. Tried the versions from OpenSSL on Windows (inexplicably renamed in the other direction). Tried masquerading these dlls as "crypto.dll", which just caused other errors.
Once again, I'd love for a more satisfying answer to exist (hint hint, future readers).

Installing mesos egg for python 2.7

I've installed mesos 0.26 successfully on a vm machine.
The installation has been performed on an ubuntu trusty thar system
by following this manual:
https://open.mesosphere.com/getting-started/install/
So far so good. I wanted to write a tiny python framwork.
For this I need to install the eggs via easy_install:
(I've downloaded the eggs accordingly for the trusty thar ubuntu and the 0.26 mesos):
wget http://downloads.mesosphere.io/master/ubuntu/14.04/mesos-0.26.0-py2.7-linux-x86_64.egg
easy_install mesos-0.26.0-py2.7-linux-x86_64.egg
all went fine, however, if I start python in the shell
and type in
import mesos.interface
I get the message: ImportError: No module named interface
As someone suggested, it may be that there is no longer a binding for python, or that they have renamed the API calls. Well, I looked in the version updates here:
http://mesos.apache.org/documentation/latest/upgrades/
Since the transition from 0.19.x to 0.20.x there hasn't been any changes regarding the mesos.interface part, or at least they are not mentioning it here.
To increase the confusion I also get the following error message when I'm typing in python: import mesos.native
There I receive: ImportError: No module named interface.mesos_pb2. To put it into a nutshell: what is going wrong here, and how can it be fixed? And yes, I've googled various web pages, with terms such as "mesos python bindings", mesos +api +python, etc. And yes, I have also consulted the official mesos webpage. There are nice refences for Java and C++ but not for python, or at least they are very well hidden.
Thanks in advance for any hints.
Solved. For what reasons ever:
export PYTHONPATH=${PYTHONPATH}:/usr/lib/python2.7/site-packages/
is required to set the PYTHONPATH. After that step it works like a charm.

"R6034 An application has made an attempt to load the C runtime library incorrectly" after pygtk being installed

I'm using python 2.7.9 and encountered a problem when installing pygtk.
It displayed "Runtime error!...R6034 An application has made an attempt to load the C runtime library incorrectly" when installing numpy/scipy after pygtk being installed.
I tried to figure it out by searching it in stackoverflow and found two similar questions: Runtime error R6034 in embedded Python application and An application has made an attempt to load the C runtime library incorrectly.
So following the first one, I deleted the path corresponding to msvcr90.dll, however, it still cannot work. Then I chose to simply delete msvcr90.dll; at this time, this error wasn't presented when installing numpy/scipy, however, these two modules cannot work when simply typing "importing numpy/scipy".
I also renamed gtk-2.0 following the second one. Then numpy and scipy can be successfully installed. But it displayed "Error processing line 3 of C:\Python27\lib\site-packages\pygtk.pth" when installing matplotlib using pip.
I'm really confused about it. Can anybody provide some methods to fix it?
I've installed Python and PyGTK on 5+ machines, at least two of them brand new, clean builds of Win 7.
I've got the An application has made an attempt to load the C runtime library incorrectly error whenever I install a Python package as a windows installer (rather than using pip) on all these machines. It's annoying, but has never made a jot of difference, both Python and Gtk function correctly.
You've deleted msvcr90.dll, and that is why you get your Error processing line 3... If you look at this file, you'll see that line 3 is import runtime, and if you look further into the 'runtime' package, you'll see that this then tries to find the missing dll.
I think your best bet is to try to restore the missing file. If it's still in your recycle bin - great!
If not, the best thing to do is reinstall the Visual C++ runtime library
I made this video to show my way: https://www.youtube.com/watch?v=s6jhR1VBfeU. I use Anaconda to embedded Python in my C++ application. I simply changed "msvcr90.dll" to "msvcr90.dll_hihi" in 3 folders:
C:\Users\your user\Anaconda2\Library\bin, C:\Users\your user\Anaconda2 and C:\Program Files\Intel\iCLS Client (for x64)

Numpy not installing, also "Can't find a usable init.tcl in the following directories:"

I am trying to start the newcoder.io data vizualization tutorial but am having a difficult time installing numpy on Windows (8.1, python 2.7).
When I go to install it using pip the process never completes, even if I leave it for an hour or more. It doesn't give me any errors or anything either so I don't know how to track down what is causing this.
Here is what is looks like:
(datavizproj)PS C:\Users\Ray\github\new-coder\dataviz> pip install numpy
Collecting numpy
Using cached numpy-1.9.2.tar.gz
Installing collected packages: numpy
Running setup.py install for numpy
Any thoughts on what to do? Should I delete the cached file and have it redownload it? I looked in Python27/lib/site-packages and didn't even see numpy and I thought that is where the file should be kept after pip finds them.
EDIT: I added "Can't find a usable init.tcl in the following
directories:" to the title to help anyone else who has this separate problem find the solution posted below.
Numpy is implemented in C and thus requires a C compiler to install. To circumvent the issue, use a precompiled installer from the Source Forge page here. Then try to import to verify the installation.
import numpy # see whether it's been installed
I was able to track down my issue (thanks Malik Brahimi, you led me on the right track to figure this out)
My issue was that I installed the 64bit version of Python, and pip can't install a 64 bit version of numpy because there is no official source.
My solution was to remove python and reinstall a 32 bit version as I don't actually need 64bit and apparently there is better compatibility for modules using 32bit.
I came to another problem later on, where the init.tcl file could not be found when I was running a program that use matplotlib. Python was searching for the init.tcl in python27/bin/tcl8.5 but the correct directory is python27/tcl/tcl8.5 . To fix this I added 2 system variables: TCL_LIBRARY, with the path C:/Python27/tcl/tcl8.5 and TK_LIBRARY, with the path C:/Python27/tcl/tk8.5
you may want to retry using easy_install?
Otherwise, try deleting any cached items.

Has anybody been able to install PyWeka?

I need to install in python 2.6 or 2.7 for windows the library PyWeka0.3dev, It says it requires setuptools, which I installed but then they told me it was a deprecated instalation library and I installed distribute, then I downloaded the PyWeka compressed package and each time I try to install it neither with setup.py nor with easy_install (where it says something like no module ez_setup). Can anybody give me a clue about how to do this?
As mentioned to you via Aardvark (yes, I am omnipresent), the module in question is broken. You can't easy_install it. It's a bug in PyWeka.
You can download the file from PyPI, http://pypi.python.org/pypi/PyWeka/0.3dev, and unpack it.
In the file setup.py, remove the following two lines:
from ez_setup import use_setuptools
use_setuptools()
And install it by running
python setup.py install
You need to have installed numpy and NamedMatrix (which has the same bug as PyWeka) first.
However, you mentioned you are on Windows. I strongly doubt that PyWeka will work on Windows. There are some Unix specific code in it.
And I still really want to know why the authors are reading files by calling cat from subprocess. That seems pretty pointless and is together with the broken install, good enough reason for me to keep far away from that module. I suspect it's authors simply have no idea what they are doing.
That, or they are geniuses.
A punk/goth approach to programming probably has the right to be..
To get the C-compliation part to work on windows you either need (1) to have Visual Studio of the same version that was used to compile the python version you are using, or (2) mingw which is a bit trickier to set up.

Categories

Resources