I'm trying to add pretty printing for STL objects in my Eclipse/CDT (Mars release) to remote debug application running in an ARM board.
I can succesfully debug my application using Eclipse and gdbserver. For this purpose I use the following gdbinit file:
set sysroot remote:/
Then I'm trying to follow the steps available in teh Eclipse Wiki to have the pretty printing for STL structures:
http://wiki.eclipse.org/CDT/User/FAQ
I downloaded successfully the files from SVN, and added the indicated lines to my gdbinit file, which became:
set sysroot remote:/
python
import sys
sys.path.insert(0, '/home/rvcpu/prettyprinting')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
When I start the Debug session I get the following error on the gdb trace:
418,226 12-gdb-set target-wide-charset UTF-32
418,227 12^done
418,227 (gdb)
418,228 13-gdb-set dprintf-style call
418,228 13^done
418,228 (gdb)
418,232 14source /home/rvcpu/CodeSourcery/Sourcery_G++_Lite/bin/gdbinit
418,232 &"source /home/rvcpu/CodeSourcery/Sourcery_G++_Lite/bin/gdbinit\n"
418,232 =cmd-param-changed,param="sysroot",value="remote:/"
I believe I must indicate to GDB, somehow, that the python script is located on my host computer, not the target. Does anyone know how to do that?
Thanks,
Bernardo
You should add that lines to .gdbinit on host machine and python directory with "libstdcxx" library should be on host machine too.
And if you have python directory in subdirectory "prettyprinting", you should set that directory which contain libstdcxx directory.
So if you has printers here:
/home/rvcpu/prettyprinting/python/libstdcxx/v6/
you need to insert
/home/rvcpu/prettyprinting/python/
to your sys.path in python code of .gdbinit.
Related
(I have already resolved this issue but it cost me two weeks of my time and my employer a couple of grand, so I'm sharing it here to save some poor soul.)
My company is converting our application from 32-bit to 64-bit. We create an executable using py2exe, using the bundle=2 option. The executable started crashing as soon as it tried to render a matplotlib plot.
Versions:
python==2.7.13,
matplotlib==2.0.0,
numpy==1.13.1,
py2exe==0.6.10a1
I tracked the error to the numpy library. Numpy calls numpy.linalg._umath_linalg.inv() and the program abruptly exits with no error message, warning, or traceback.
_umath_linalg is a .pyd file and I discovered that this particular .pyd file doesn't like being called from library.zip, which is where py2exe puts it when using bundle option 2 or 1.
The solution is to exclude numpy in the py2exe setup script and copy the entire package folder into the distribution directory and add that directory to the system path at the top of the main python script.
Good day all. First time stack overflow has not previously answered an issue that I have. My problem is exactly like the one posted here, except I am running windows:
Google App Engine Launcher is not running my hello world for Python Mac
The only thing the log gives me is this
2016-08-18 13:39:13 Running command:
"['C:\Users\Kesi\Desktop\Documents\Computer
Science\Udacity\Intro to backend\hello-udacity\main.py',
'C:\Program Files (x86)\Google\google_appengine\dev_appserver.py',
'--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000',
'C:\Users\Kesi\Desktop\Documents\Computer Science\Udacity\Intro
to backend\hello-udacity']"
Any suggestions are greatly appreciated.
Converting comments to an answer.
The 1st argument in the command list from your message is 'C:\Users\Kesi\Desktop\Documents\Computer Science\Udacity\Intro to backend\hello-udacity\main.py', preceeding the dev_appserver.py suggests a configuration problem.
In the google app engine preferences section there is a place to specify the path to executable python file. That should not be set to your app's python file (as you have it), but to the actual python executable (from your python installation) - which executes dev_appserver.py (the 2nd arg in the command list) which in turn loads the subsequent command list args including one which is the one specifying your app code's location - the last one in your case.
The python executable could be a python.exe or pythonw.exe according to the Executing scripts section of Using Python on Windows doc:
Python scripts (files with the extension .py) will be executed by
python.exe by default. This executable opens a terminal, which stays open even if the program uses a GUI. If you do not want this to
happen, use the extension .pyw which will cause the script to be
executed by pythonw.exe by default (both executables are located
in the top-level of your Python installation directory). This
suppresses the terminal window on startup.
the issue: running Python's matplotib from a Windows virtual environment as reported & discussed Github ticket 93 and a relevant suggested fix here.
Code (myp.py):
import matplotlib.pyplot as pl
import Tkinter as tk
# insert code to read/load mydata
pl.plot(mydata['foo'],mydata['bar'],'*')
Tcl Error:
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Python27/lib/tcl8.5 C:/Users/Remi/MyVirtEnv/lib/tcl8.5....(ect)
Fix attempt 1: as suggested in ticket above, I added the following env. variables to path in batch file activate.bat located in C:/Users/Remi/MyVirtEnv/Scripts/:
set "TCL_LIBRARY=C:\Python27\tcl\tcl8.5"
set "TK_LIBRARY=C:\Python27\tcl\tk8.5"
Not resolved this way. Potentially relevant info: using PyCharm IDE with the following configuration:
Environment variables: PYTHONUNBUFFERED=1
Python interpreter: python 2.7.10 virtualenv at C:\Users\Remi\MyVirtEnv
"buttons checked": Add content roots and Add source roots to PYTHONPATH
Any help I could get would be much appreciated.
After adding the following environment variables to path in batch file activate.bat located in the virtual environment, e.g.: C:/Users/Remi/MyVirtEnv/Scripts/:
set "TCL_LIBRARY=C:\Python27\tcl\tcl8.5"
set "TK_LIBRARY=C:\Python27\tcl\tk8.5"
it is able to launch IDLE in virtual environment.
Make sure the path is valid, e.g. "C:\Python27\tcl\tcl8.5"
I am learning basic GUI in Python, and I came across a sample example to read file name from file explorer on Stack Overflow.
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)
This particular script is working fine when I am trying to run it in IDLE, but the same is not running if I am trying from command prompt in windows 7.
Python Version: 2.7. Here is the output error which I get.
>>> from Tkinter import Tk
>>> from tkFileDialog import askopenfilename
>>> Tk().withdraw()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\Lib\lib-tk\Tkinter.py", line 1685, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Python27/lib/tcl8.5 D:/PyProj/lib/tcl8.5 D:/lib/tcl8.5 D:/PyProj/library D:/library D:/tcl8.5.2/library D:/tcl8.5.2/library
This probably means that Tcl wasn't installed properly
Any pointer to what I am missing here can be of great help.
You just need to copy two folders from tcl folder to the Lib folder
tcl8.5 and tk8.5
In case you are using Virtualenv on Windows I found a solution here: https://github.com/pypa/virtualenv/issues/93
I copied the "tcl" folder from C:\Python27\ over to the root of the new Virtualenv, Tkinter.Tk() shows a new window without throwing an exception.
I am running Python 2.7 on Windows 7.
Hit a similar problem after installing Activestate Python and TCL. I found the following page solved the problem for me: ActiveState Python install problem. The fix was to copy the contents of C:\Python27\tcl into C:\Python27\Lib.
Another potential solution (given by user i-shenl in a different ActiveState thread on the same issue) is to set the environment variable $TCL_LIBRARY to point to the tcl library folder ("C:/Python27/tcl", in the question). If you set this system-wide or account-wide (via System Properties), it will affect other programs that use a TCL Library (if any are installed). If you're using Powershell, you can set this variable in your profile to limit its affects to programs run from the shell.
I hit the same problem on Ubuntu 17.04 with virtualenvwrapper for 64 bit Python 2.7
I add tk and tcl library paths in local postactivate script
Go to your virtualenv: workon your-env-name
Edit local postactiave script with your favourite editor, for ex:
gedit $VIRTUAL_ENV/bin/postactivate
Locate tk and tcl library paths. In postactivate script, export TK_LIBRARY and TCL_LIBRARY with appropriate paths. Add this lines to your script with modified paths:
TK_LIBRARY=/home/kamil/anaconda2/pkgs/tk-8.5
TKPATH=/home/kamil/anaconda2/pkgs/tk-8.5
TCL_LIBRARY=/home/kamil/anaconda2/lib/tcl8.5
export TCL_LIBRARY TK_LIBRARY TKPATH
Restart your virtualenv: deactivate and workon your-env-name again.
If you are hitting this kind of error in a python -m venv NAME kind of virtual environment (and you actually have tcl installed in your system), then you need to export the paths similarly as suggested by Kamil Czerski in a previous post for virtualenv.
To find out what are your TK and TCL paths, run a python script outside of the venv (source):
import tkinter
root = tkinter.Tk()
print(root.tk.exprstring('$tcl_library'))
print(root.tk.exprstring('$tk_library'))
Open your venv configuration file bin/activate and find the place where they export PATH and insert after this (insert correct paths from step 1):
TCL_LIBRARY="/tcl/path/from/step/1"
TK_LIBRARY="/tk/path/from/step/1"
TKPATH="/tk/path/from/step/1"
export TCL_LIBRARY TK_LIBRARY TKPATH
Deactivate (if it was activated) and source again your venv:
deactivate
source bin/activate
The "Tcl missing"-error should be gone.
IDLE is probably setting the path required for TCL. To find out what path is being used by IDLE, compare the output of sys.path from IDLE and without IDLE. Then you can add the location of init.tcl either using an environment variable or programatically. See Xenomorph suggestion.
All you need to do is copy tcl 8.6 and tcl 8.5 from tcl file to Lib file on in python.
Python-tcl-tcl8.5 to Python-Lib
Go to directory in which all of your python dependencies are stored
Example:
Python37
-DLLs
-Doc
-etc
-include
-Lib
-libs
-Scripts
-tcl
-python.exe
Go to tcl folder, copy the tcl8.5 and tk8.5 folder
Paste these folders in the Lib folder
This solution works for Windows 10 users
I'm having trouble running some codes that import cx_Oracle in command line, though the same codes work in console. Is there anything else I will need to set up in order to get this to work via command line please?
Saved just one line of code "import cx_Oracle" as test.py.
Run this line in ide (Spyder), iPython Notebook => no issues
run this by opening a command line window from the same folder the .py file is saved in, and run python test.py and encounter the below:
import cx_Oracle
ImportError: DLL load failed: %1 is not a valid Win32 application.
Not sure if there is anything additional I will need to set up to run cx_Oracle via command line? Have tried all the suggestions on setting PATH, ORACLE_HOME, re-installing but could not get this to work. versions that i'm using are
Python: 2.7
cx_Oracle: cx_Oracle-5.1.3-11g.win-amd64-py2.7
instant client: 12.1.0.0
Windows: 7 Enterprise
I also found this kind of problem.
Look at "not a valid Win32 application" this sentence, so I decide to change cx_Oracle to cx_Oracle-5.1.3-11g.win-32-py2.7. Luckly, it does work.