clang's python binding throws an exception when get_children is called - python

I'm trying to run an example found here, but it always fails to execute. After some debugging, I found out that the node.get_children() causes the exception, and here's the traceback:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "C:\Python27\lib\site-packages\clang\cindex.py", line 1383, in visitor
children.append(child)
AttributeError: 'str' object has no attribute 'append'
I'm using LLVM 4.0.1 on Windows, and I installed clang via pip (tried both clang3.5 and clang4.0.post1).
Here's my LD_LIBRARY_PATH: C:\Program Files\LLVM\bin, which I added into my
PATH like this: %LD_LIBRARY_PATH%;%PYTHONPATH%;...rest of path...
I got the same error after installing LLVM5.0 and cloning clang from github.
EDIT: I used Python2.7, but after switching to Python 3.6.3 everything works ok.

Switching to Python 3.6 solved the problem.

Related

julia.install() fails on python import error

I am trying to run a Julia script from python. I have Julia 1.6.4 installed (also tried 1.7.3) and installed pip install julia from Pycharm's terminal in the virtual environment. When importing julia and then running julia.install() I get the following error message:
I use Pycharm with a virtual environment with Python 3.9.7 for my project. However, I have also tried different python versions in different virtual environments or by using the base python installed. All give the same error.
Also, ~/.julia/packages/PyCall/*/deps/build.log does not exist for me.
[ Info: Trying to import PyCall...
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\site.py", line 73, in <module>
import os
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\os.py", line 29, in <module>
from _collections_abc import _check_methods
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\_collections_abc.py", line 12, in <module>
GenericAlias = type(list[int])
TypeError: 'type' object is not subscriptable
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\<user>\PycharmProjects\<project>\venv\lib\site-packages\julia\tools.py", line 118, in install
raise PyCallInstallError("Installing", output)
julia.tools.PyCallInstallError: Installing PyCall failed.
** Important information from Julia may be printed before Python's Traceback **
Some useful information may also be stored in the build log file
`~/.julia/packages/PyCall/*/deps/build.log`.```
Julia needs to have PyCall installed
PyCall in Julia needs to be configured to use the same Python that you are using to call Julia from
For more information see this post:
I have a high-performant function written in Julia, how can I use it from Python?

"Name Error: name 'get_ipython' is not defined" while preparing a debugging session via "import ipdb"

I'm trying to install and use ipdb (IPython-enabled pdb) on Python 3.3.5 32 bit on Win10 using PIP 8.1.2.
I've installed via PIP (had to install it seprately) in windows cmd with no errors:
pip install ipdb
I wrote a simple test script expecting to stop in debugger before printing 'test' string, ipdb_test.py:
import ipdb
ipdb.set_trace()
print('test')
When running it from IDLE editor the following exceptions show up:
Traceback (most recent call last):
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 44, in <module>
get_ipython
NameError: name 'get_ipython' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/temp/ipdb_test.py", line 1, in <module>
import ipdb
File "C:\Python33.5-32\lib\site-packages\ipdb\__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 51, in <module>
(...)
File "C:\Python33.5-32\lib\site-packages\prompt_toolkit\terminal\win32_output.py", line 266, in flush
self.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
As the issue seemed to be related to IPython, I've checked that the version installed while resolving ipdb dependencies was: "ipython-5.1.0".
The WA solution for the issue occured to be a fallback to version 4.2.1 of IPython:
pip install "ipython<5"
(...)
Successfully uninstalled ipython-5.1.0
Successfully installed ipython-4.2.1
After that ipdb halted on a breakpoint as expected:
$ python C:\temp\ipdb_test.py
WARNING: Readline services not available or not loaded.
WARNING: Proper color support under MS Windows requires the pyreadline library.
You can find it at:
http://ipython.org/pyreadline.html
Defaulting color scheme to 'NoColor'
> c:\temp\ipdb_test.py(3)<module>()
1 import ipdb
2 ipdb.set_trace()
----> 3 print('test')
ipdb>
It may be a valid case to contact the IPython project team on the issue, meanwhile I find an initial task of running a debug session completed.

Can no Longer open Spyder IDE for Python Programming

I installed Python 3.4 on my Windows 7 laptop several months ago as part of Anaconda (https://www.continuum.io/downloads). My installation included the Spyder IDE, and I have successfully been using Spyder for Python programming.
However, since yesterday, I have been unable to open Spyder. I typically open Spyder via the Start Menu, but now, when I try to click on the Spyder icon in the Start Menu, I get no response. I then tried to go directly to the spyder.exe file in the Scripts folder in the directory where Anaconda is installed. When I clicked on this the first time, the following message flashed quickly and then disappeared:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 114, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
I double-clicked on Spyder.exe a second time, and this time, received the following message:
kfile.py", line 146 in lock
symlinke(str(os.getpid()), self.name)
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\utils\external\lockfile.py", line 87, in symlink
os.rmdir(newlinkname)
OSError: [WinError 145] The directory is not empty: 'C:\\Users\\Aniket\\.spyder2-py3\\spyder.lock.1459432906109.newlink'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 106, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
Both of these messages flashed very quickly and then disappeared - I captured them by quickly pressing Print Screen when they appeared. It's not evident to me what the error messages imply, nor what would have caused this. It's possible that I closed Spyder while some function was running, or that Spyder crashed and caused some persistent error. Does anyone know how I can fix this?
I had a similar problem of Spyder 2 not starting. My installation is part of Anaconda, on Win7 64-bit OS. I tried all the solutions outlined here and here, but they did not work for me. From the command line, I got the following error(s) when trying to reset spyder:
U:\>python -c "from spyderlib.spyder import main; main()" --reset
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 48, in <module> from PySide import __version__ # analysis:ignore
ImportError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 40, in check_qt from spyderlib import qt File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 50, in <module>
raise ImportError("Spyder requires PySide or PyQt to be installed")
ImportError: Spyder requires PySide or PyQt to be installed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 48, in <module> requirements.check_qt()
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 50, in check_qt % (qt_infos['pyqt']+qt_infos['pyside']))
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 25, in show_warning
raise RuntimeError(message)
RuntimeError: Please check Spyder installation requirements:
PyQt4 4.6+ (or PySide 1.2.0+) is required.
What surprised me was that spyder worked fine till yesterday, and I just did a full update yesterday as follows:
conda update --all
So I again updated spyder today with the following:
conda update spyder
And the following package plan was presented to me:
The following packages will be UPDATED:
spyder: 2.3.7-py35_3 None://None/<unknown> --> 2.3.8-py35_1
spyder-app: 2.3.7-py35_0 --> 2.3.8-py35_0
The following packages will be DOWNGRADED due to dependency conflicts:
matplotlib: 1.5.3-np111py35_1 --> 1.5.1-np111py35_0
pyqt: 5.6.0-py35_0 --> 4.11.4-py35_7
qt: 5.6.0-vc14_0 [vc14] --> 4.8.7-vc14_9
[vc14]
qtconsole: 4.2.1-py35_2 --> 4.2.1-py35_0
After the update, spyder works fine now.
In essence, my problem was due to dependency conflicts.
I ran into the same issue. The following worked for me
Please close Spyder IDE, in Anaconda Prompt run
conda update spyder
then
spyder --reset
Restart Spyder
Had the same exact problem as you a few days ago and reinstalling won't work so I went to:
C:\Users\'YourName'\\.spyder2-py3
delete every spyder, lock file/folder in it and relaunch.
I know this is an old thread but having just had the same problem an answer that worked for me from https://github.com/spyder-ide/spyder/issues/3005
My problem appeared to be that the status of spyder was still running so wouldn't open. To fix this you need to look for a directory called .spyder2 in your Users\ directory, then find a file called spyder.lock and remove it.
My solution:
I uninstalled Anaconda spyder
Removed all directories of it from
c: programs/
and c:users/Username/
and c:users/username/AppData/local
and c:users/username/AppData/
I downloaded a newer version of Anaconda Spyder and installed it.
It's all fine now.
You might get additional information if you run
from spyder.app import start
start.main()
as a python script. For example I got following output:
Traceback (most recent call last):
File "C:\python_env\workspace\TechDiff\src\demo.py", line 1, in <module>
from spyder.app import start
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\app\start.py", line 24, in <module>
from spyder.config.base import get_conf_path, running_in_mac_app
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\config\base.py", line 25, in <module>
from spyder.utils import encoding
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\utils\encoding.py", line 23, in <module>
from spyder.py3compat import (is_string, to_text_string, is_binary_string,
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\py3compat.py", line 77, in <module>
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (C:\python_env\App\WinPython\python-3.10.1.amd64\lib\collections\__init__.py)
=> Maybe for Python 3.10 the import of collections needs to be fixed.
=> Try to use 3.9
I've got exactly the same error messages before, and I fixed it by installing spyder again under anaconda:
conda install spyder
Well it says it is missing PyQt4.dll, which you can check by: searching pyqt4 in your anaconda3 directory.
There are several possibilities:
it is still in: ~\Anaconda3_x86\Library\plugins\designer
That would mean python can't find since it ain't searching in this directory, I highly doubt that possiblity, since that would mean you'd have tweaked some code.
it ain't anywhere
Maybe you or more likely one of your programs did deleted it per accident?
it isnt in: ~\Anaconda3_x86\Library\plugins\designer
I also doubt this possibilty since it would mean the file has been moved...
However you can fix that by reinstalling spyder as mentioned by xuwei.

GDB pretty printing ImportError: No module named 'printers'

I'm trying to add pretty printing for STL in my GDB on Ubuntu 14.04. Some details on the tools:
OS: Ubuntu 14.04
gdb version: 7.7
python version: 2.7.6
python3 version: 3.4.0
But after I setup exactly as what the instruction said. I still get the following errors:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/__init__.py", line 19, in <module>
from printers import register_libstdcxx_printers
ImportError: No module named 'printers'
/home/jerry/.gdbinit:6: Error in sourced command file:
Error while executing Python code.
Reading symbols from main...done.
Then I haved double checked my pretty printing installation directory. Under the directory /home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/, I can clearly see I have the printers.py file. And I also view the content of printers.py, I'm sure it also has the register_libstdcxx_printers class. Why the python interpreter is still complaining the printers module is missing? This seems really strange to me.
I just tried something myself, and luckily, now it's working. At least it can print out the map and vector content as expected. Here is what I did:
Since it's complaining that it can't find the printer.py module, then I think should probably I tell python interpreter where this file is located. So I first added this extra line to my ~/.gdbinit:
sys.path.append("/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6")
(After the line sys.path.insert(0, '/home/jerry/myLib/gdb_stl_support/python') )
Then running gdb again, I got the following error:
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/printers.py", line 1247, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "/usr/share/gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
/home/jerry/.gdbinit:7: Error in sourced command file:
Error while executing Python code.
Given the error information, I edited the ~/.gdbinit file and commented the line register_libstdcxx_printers (None).
And then after running gdb, it works.
But I'm still wondering if directory in sys.path is searched recursively? I mean in my mind, the python interpreter should work like this: once you have added one directory to sys.path, then the subdirectory under that directory will also get searched for a module file.

Get AttributeError after upgrading to IPython13

I upgraded my IPython installation with pip, and when I use ipython, it failed like this:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Shell'
But when I try $(which ipython), it starts up normally.
What may be the reason of that AttributeError?
Look under ~/.ipython. There's probably a configuration script there that is using the old API.
It turns out that an alias in .bashrc overrode ipython in $PATH, and it was set to be an old version of ipython

Categories

Resources