Debug Python

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

It looks like it was not properly installed. Therefore I ran:

C:\Winpdbsource\winpdb-1.4.8>python setup.py install -f
running install
running build
running build_py
running build_scripts
copying winpdb.bat -> build\scripts-2.6
copying rpdb2.bat -> build\scripts-2.6
running install_lib
copying build\lib\rpdb2.py -> C:\Python26\Lib\site-packages
copying build\lib\winpdb.py -> C:\Python26\Lib\site-packages
byte-compiling C:\Python26\Lib\site-packages\rpdb2.py to rpdb2.pyc
byte-compiling C:\Python26\Lib\site-packages\winpdb.py to winpdb.pyc
running install_scripts
copying build\scripts-2.6\rpdb2.bat -> C:\Python26\Scripts
copying build\scripts-2.6\winpdb.bat -> C:\Python26\Scripts
copying build\scripts-2.6\winpdb_.pyw -> C:\Python26\Scripts
copying build\scripts-2.6\winpdb_inst.py -> C:\Python26\Scripts
running install_egg_info
Writing C:\Python26\Lib\site-packages\winpdb-1.4.8-py2.6.egg-info


Right now when I
import rpdb2

I get:

C:\Python26\lib\site-packages\rpdb2.py:308: DeprecationWarning: the sets module is deprecated
import sets
C:\Python26\lib\site-packages\rpdb2.py:313: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
import popen2
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python26\lib\site-packages\rpdb2.py", line 343, in <module>
import xmlrpc.server as SimpleXMLRPCServer
ImportError: No module named xmlrpc.server

Thanks.
Jair Santos
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Debug Python

Post by wmayer »

This is the relevant part of rpdb2.py

Code: Select all


try:    
    import SimpleXMLRPCServer 
    import xmlrpclib
    import SocketServer
    import commands
    import copy_reg
    import httplib
    import thread

except:
    #
    # The above modules were renamed in Python 3 so try to import them 'as'
    #
    import xmlrpc.server as SimpleXMLRPCServer
    import xmlrpc.client as xmlrpclib
    import socketserver as SocketServer
    import subprocess as commands
    import copyreg as copy_reg
    import http.client as httplib
    import _thread as thread
So, you see that for Python2 you need the modules inside the try/except block, i.e. SimpleXMLRPCServer, ...
Is this a proper Python installation under C:\Python26\ or did you install only WinPdb there?
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

Hello.

Yes, that's exactly what I have in in rpdb2.py in the directory C:\Python26\Lib\site-packages. Python is installed under C:\Python26.

When googling the rror I've found this issue reported as a bug on winpdb. See below.

https://code.google.com/p/winpdb/issues/detail?id=6

https://code.google.com/p/winpdb/issues/detail?id=13

I believe that there is something wrong with my installation.

thanks.
Jair Santos
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

Hi.

I uninstalled both python and wxPython. The I reinstalled again.

On FC, the comand import rpdb2 still returns

import rpdb2
C:\Python26\lib\site-packages\rpdb2.py:308: DeprecationWarning: the sets module is deprecated
import sets
C:\Python26\lib\site-packages\rpdb2.py:313: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
import popen2
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python26\lib\site-packages\rpdb2.py", line 343, in <module>
import xmlrpc.server as SimpleXMLRPCServer
ImportError: No module named xmlrpc.server

Thanks.
Jair Santos
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Debug Python

Post by wmayer »

Here are the steps how I did it:

1. Use the LibPack and create a directory DLLs inside the "bin" folder
2. Download https://winpdb.googlecode.com/files/winpdb-1.4.8.zip and copy the files rpdb2, rpdb2.py, winpdb, winpdb.py to DLLs
3. Download http://switch.dl.sourceforge.net/projec ... 1-py26.exe and choose a fresh directory. You don't need to install it into an existing Python installation.
4. From this installation copy "wxversion.py" and the directories "wx" and "wxPython" to DLLs
5. In DLLs create the file wx.pth with the content: wx-2.8-msw-unicode
6. Open a terminal window and cd to DLLs. Run "python winpdb.py"

Make sure that FreeCAD\bin is in your system path so that it finds the python.exe
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

Thanks.
I followed the procedure step by step:

C:\FreeCADLibs_8.0_x86_VC9\bin\DLL>python winpdb.py
C:\FreeCADLibs_8.0_x86_VC9\bin\DLL\rpdb2.py:308: DeprecationWarning: the sets mo
dule is deprecated
import sets
C:\FreeCADLibs_8.0_x86_VC9\bin\DLL\rpdb2.py:313: DeprecationWarning: The popen2
module is deprecated. Use the subprocess module.
import popen2
Traceback (most recent call last):
File "winpdb.py", line 297, in <module>
import rpdb2
File "C:\FreeCADLibs_8.0_x86_VC9\bin\DLL\rpdb2.py", line 343, in <module>
import xmlrpc.server as SimpleXMLRPCServer
ImportError: No module named xmlrpc.server

C:\FreeCADLibs_8.0_x86_VC9\bin\DLL>
Jair Santos
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Debug Python

Post by wmayer »

I guess you have set some environment variables or some strange settings in your registry which have an impact on Python. That's the only explanation I have.
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

That's what think as well. I'll check this.

Thank you.
Jair Santos
jairds
Posts: 33
Joined: Mon Mar 18, 2013 7:20 pm

Re: Debug Python

Post by jairds »

It's a real pain.
I started to clean up the mess like PATHs , uninstall programs, etc.. I looks like there was a trap somewhere. When I ran FC , VS said that we should update the build. Running it I got errors like Error 1 error PRJ0019: A tool returned an error code from "VectorPy.xml" FreeCADBase FreeCADBase . They are all over the place. :evil:

It seems that it is something related with the manifest. I am googling around but so far no solution.

Regards.
Jair Santos
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Debug Python

Post by jriegel »

We run python code in our build process to compile the .xml to cpp files. so in order to compile you need a python installed or the VS use the one from LibPack...
Stop whining - start coding!
Post Reply