How to make JEDI recognize a Python C extension - python

I am currently developing a Python module in C, and I cannot figure out how to make JEDI "see" my module.
I have set all docstrings in the C code and set every field in my setup.py, but when I edit the example.py file I use for testing and try to display documentation in vim using Shift+K, I get an error saying:
Exception, this shouldn't happen.
Traceback (most recent call last):
File "/home/beben/.vim/bundle/jedi-vim/jedi_vim.py", line 268, in show_documentation
definitions = script.goto_definitions()
File "/home/beben/.vim/bundle/jedi-vim/jedi/jedi/api/init.py", line 365, in goto_definitions
names = [s.name for s in definitions]
AttributeError: 'NoneType' object has no attribute 'name'
No documentation found for that.
After reading jedi's documentation, I understand that it uses Pydoc to gather information on the module.
When I run Pydoc mymodule, the documentation is correctly displayed.
Is there something more that I need to add to my code to be recognized by JEDI?

Related

pyinstaller executable has errors but is completely fine when opening .py file on terminal

I'm trying to make an executable file for a project so my friends don't need to install python, using pyinstaller
When using pyinstaller with "-w"
The executable shows an Attribute error
Traceback (most recent call last):
File "main.py", line 7, in <module>
display = calendar_object.make_calendar()
AttributeError: 'Calendar' object has no attribute 'make_calendar'
but when I open main.py in the terminal it is completely fine.
When using pyinstaller without "-w"
It opens and closes immediately, and yes I have a while loop and an input inside so I'm guessing there's again, something wrong with my file
Temporary Solution:
Inserting all the separate files into one file.
Code Sample:
main.py
calendar.py
You seem to be using a name for your class that is mimicking the python internal calendar class.
Rename your class and you should be fine

Python version conflict. Jhbuild not reading Jhbuildrc?

I was about to set up pygobject for gtk+3. This http://python-gtk-3-tutorial.readthedocs.org/en/latest/install.html#id2 page says I need Jhbuild. I went ahead and installed that. But, it gives me traceback
Traceback (most recent call last):
File "/usr/bin/jhbuild", line 6, in <module>
import __builtin__
ImportError: No module named '__builtin__'
Which obviously is due to wrong version of python(my default is python3).
So, I found this page https://wiki.gnome.org/Projects/Jhbuild/Dependencies/ArchLinux
Which suggests to add
os.environ['PYTHON'] = '/usr/bin/python2'
line to ~/.config/jhbuildrc which I did. When I run jhbuild again it spews the same traceback.
I tried putting the file as ~/.jhbuildrc. Doesn't work either.
So, I'm stuck here. Any help would be appreciated.
I'm on Arch Linux, fwiw.
You probably want to set PYTHON=/usr/bin/python2 when you ./autogen.sh --simple-install for jhbuild itself. The jhbuildrc file is only used for things it builds.
See also: https://wiki.archlinux.org/index.php/JHBuild

Sphinx: autodoc fails for certain modules due to hardware-specific libraries raising exceptions on the dev machine

I'm working in a project involving the Raspberry Pi and the PiFace interface module. The project is being developed in Python and I have run into a problem when trying to auto document some modules with Sphinx. We are using the pifacedigitalio library, however, even though I have installed said library on the development machine, Sphinx refuses to document the module and complains that it's throwing exceptions due to hardware not being present. The hardware isn't present because this is the development machine. For testing the software, we just use a conditional if hwpresent then skip but I actually want to document those parts through Sphinx. The error produced when doing make html is:
/home/user/current/working/docs/src.rst:10: WARNING: autodoc: failed to import module u'src.billete'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 335, in import_object
__import__(self.modname)
File "/home/user/current/working/src/bill.py", line 4, in <module>
piface_obj = piface.PiFaceDigital()
File "/usr/local/lib/python2.7/dist-packages/pifacedigitalio/core.py", line 82, in __init__
self.init_board()
File "/usr/local/lib/python2.7/dist-packages/pifacedigitalio/core.py", line 107, in init_board
h=self.hardware_addr, b=self.bus, c=self.chip_select))
NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).
Is there a way to avoid Sphinx from interpreting the code and just parse the source? I tried to modify pifacedigitalio/core.py by hand using dummy returns but Sphinx just freezes then.
You have to put a directory in your PYTHONPATH that has Mock's of those modules before you run Sphinx. Check out their Doc's, but be warned that you shouldn't be screwing around with sys.modules yourself like they do in the example. Use mock.patch instead.

python select.epoll() not working

I build python2.6.1 on laptop. Build was successful. After that I tried to run python using ./python and tried to import select module
>>>import select
>>>select.epoll()
<select.epoll object at 0xb76140d0>
After that I copied the python build folder to anther laptop and tried to run python
>>>import select
>>> select.epoll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'epoll'
How to solve this problem
From the manual:
select.epoll([sizehint=-1])
(Only supported on Linux 2.5.44 and newer.)
Returns an edge polling object, which can be used as Edge or Level Triggered interface
for I/O events; see section Edge and Level Trigger Polling (epoll)
Objects below for the methods supported by epolling objects.
New in version 2.6.
And obviously distromakers can disable it in python build settings or so. It does depend on glibc only as far as I know. Also are you sure you are importing from the system select module, and not from your own module named by the same name? (check select.__file__; as a builtin module it should not have a file ;)

may be python error!

Hi
I'm not familiar with python, I just want to check something so I tried to run a .py code in linux so I wrote :
./waf wifi-olsr-flowmon --plot
which is a .py program after that whatever I want to run just see these error:
/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/wscript: error: Traceback (most recent call last):
File "/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/.waf-1.5.16-e6d03192b5ddfa5ef2c8d65308e48e42/wafadmin/Utils.py", line 197, in load_module
exec(compile(code,file_path,'exec'),module.__dict__)
File "/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/wscript", line 32, in <module>
import cflags # override the build profiles from waf
ImportError: No module named cflags
I dont know what does it mean or why it happened, would you please tell me what is the problem .
may be I should add this note that even now that I don't want to run any .py code and just wana run .cc I can't do it and see this error always
Bests
It means that Python was unable to locate a module named cflags, but the code you're running tries to import it. Perhaps you need to set PYTHONPATH, or install the cflags module.
(Also, paragraphs are your friend.)

Categories

Resources