Installing on Ubuntu again

26 views
Skip to first unread message

onebir

unread,
Apr 15, 2009, 11:25:13 AM4/15/09
to ProfitPy Discuss
Hello - I'm also having trouble installing on Ubuntu (8.04).
(Apologies if I'm making elementary error, I've messed around a tiny
bit with Python but Linux is very new to me...)

"run svn up." gives "At revision 332", which sounds fine, but
" Then "cd profit" and run "make". " gave this error:
--------------------------------------------------------------------------------------------------------------------------------------------------
onebir@onebir-laptop:/usr/lib/python2.5/site-packages/profitpy/profit$
make
make[1]: Entering directory `/usr/lib/python2.5/site-packages/profitpy/
examples'
pyuic4 -x -o ui_accountkeysdialog.py ui_accountkeysdialog.ui
make[1]: pyuic4: Command not found
make[1]: *** [ui_accountkeysdialog.py] Error 127
make[1]: Leaving directory `/usr/lib/python2.5/site-packages/profitpy/
examples'
cd: 2: can't cd to lib
cd: 2: can't cd to neuralnetdesigner
cd: 2: can't cd to strategydesigner
cd: 2: can't cd to workbench
make: *** [all] Error 2
-----------------------------------------------------------------------------------------------------------------------------------------------------
Googling suggests a file called pyuic4 is missing, but I couldn't find
it in earlier revisions of the software...

These dependencies are installed:
python 2.5, scipy 0.7.0.dev, ibpy 0.7.6-9.51, PyQt4, qt4, java 6, svn
(all available as dependencies for other ubuntu software). I'm having
trouble downloading IBTWS at the mo, but hope I'm safe in assuming
it's not the source of the problem.

Just in case it's relevant, here are contents of some of the profitpy/
& profitpy/examples directories:
onebir@onebir-laptop:/usr/lib/python2.5/site-packages/profitpy/profit$
ls
__init__.py Makefile neuralnetdesigner session strategydesigner
lib models series strategy workbench
(the widgets directory is in 'lib')

onebir@onebir-laptop:/usr/lib/python2.5/site-packages/profitpy/examples
$ ls
accountkeysdialog.py __init__.py ui_accountsummary.ui
accountsummary.py Makefile accountsummarywidget.py
ui_accountkeysdialog.ui

Troy Melhase

unread,
Apr 15, 2009, 1:19:36 PM4/15/09
to profitpy...@googlegroups.com
Try installing pyqt4-dev-tools.

onebir

unread,
Apr 15, 2009, 11:36:01 PM4/15/09
to ProfitPy Discuss
> Try installing pyqt4-dev-tools.

Thanks very much for that!
After this, make worked fine - no error messages.

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
Note for n00bs like me: pyuic4 is pyqt4's user interface compiler &
comes in pyqt4-dev-tools

Follow the procedure in the red box at the top of:
http://packages.ubuntu.com/xxxxx/i386/pyqt4-dev-tools/download
[xxxxx = gutsy/hardy/intrepid etc]
to add this to your package universe then you can use "apt-get install
pyqt4-dev-tools" to install it. (You'll have to use sudo/gksu to edit /
etc/apt/sources.list.)
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

But then this happens:
onebir@onebir-laptop:/usr/lib/python2.5/site-packages/profitpy$ ./bin/
profit_workbench
Traceback (most recent call last):
File "./bin/profit_workbench", line 12, in <module>
from profit.lib import Settings
ImportError: No module named profit.lib

I found this message relating to a similar error:
"Go up one level, e.g., "cd .." then run "./bin/profit_workbench". "
(http://groups.google.com/group/profitpy-discuss/msg/74ff45104cbab69b)
But that's exactly what I'd done...

Further digging revealed this message:
"If you're using ProfitPy from SVN, you also need to get IbPy from
SVN."
(http://groups.google.com/group/profitpy-discuss/msg/b35b995c91351655)

I'd installed using the IbPy setup script, so I did:
svn checkout http://ibpy.googlecode.com/svn/trunk/ ibpy-read-only
Which checked out revision 336.

Unfortunately, after this, running ./bin/profit_workbench produces the
same error.

Apologies once again if I'm missing something obvious...

Troy Melhase

unread,
Apr 16, 2009, 12:03:19 AM4/16/09
to profitpy...@googlegroups.com
Try adjusting your PYTHONPATH shell variable. Untested:

$ export PYTHONPATH=/usr/lib/python2.5/site-packages/profitpy:$PYTHONPATH
$ ./bin/profit_workbench

onebir

unread,
Apr 17, 2009, 1:27:56 AM4/17/09
to ProfitPy Discuss
On Apr 16, 12:03 pm, Troy Melhase <troy.melh...@gmail.com> wrote:
> Try adjusting your PYTHONPATH shell variable. Untested:
>
> $ export PYTHONPATH=/usr/lib/python2.5/site-packages/profitpy:$PYTHONPATH
> $ ./bin/profit_workbench

Thanks again, I tried what you suggested:
--------------------------------------------------------------------------------------------------
o@o-laptop:~$ export PYTHONPATH=/usr/lib/python2.5/site-packages/
profitpy:$PYTHONPATH
o@o-laptop:~$ echo $PYTHONPATH
/usr/lib/python2.5/site-packages/profitpy:
o@o-laptop:~$ cd /usr/lib/python2.5/site-packages/profitpyo@o-laptop:/
usr/lib/python2.5/site-packages/profitpy$ ./bin/profit_workbench
Traceback (most recent call last):
File "./bin/profit_workbench", line 13, in <module>
from profit.workbench.main import ProfitWorkbenchWindow
File "/usr/lib/python2.5/site-packages/profitpy/profit/workbench/
main.py", line 30, in <module>
from profit.lib.widgets.propertyeditor import PropertyEditor
File "/usr/lib/python2.5/site-packages/profitpy/profit/lib/widgets/
propertyeditor.py", line 10, in <module>
from ib.opt.message import messageTypeNames
ImportError: cannot import name messageTypeNames
--------------------------------------------------------------------------------------------------
So I searched on messageTypeNames & found the "issue with ib and
profit" thread, where a poster noted:
"I can successfully:
>>> from ib.opt.message import messageTypeNames
but only when I am in the ibpy folder. "

So I tried this:
--------------------------------------------------------------------------------------------------
o@o-laptop:/usr/lib/python2.5/site-packages/profitpy$ cd ..
o@o-laptop:/usr/lib/python2.5/site-packages$ cd ib
o@o-laptop:/usr/lib/python2.5/site-packages/ib$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ib.opt.message import messageTypeNames
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name messageTypeNames
--------------------------------------------------------------------------------------------------
So it sounds like my problem is a different. Still, I did try the
relevant suggestions in the "issue with ib and profit" thread (I'm not
sure I searched sys.path exhaustively for other versions of ib, but
since Python's not finding it, a stray copy seems unlikely to be the
problem...?)

Any further suggestions would be much appreciated!

Troy Melhase

unread,
Apr 17, 2009, 10:21:33 PM4/17/09
to profitpy...@googlegroups.com
Locate all of the ibpy packages in your PYTHONPATH. Remove them.
Then install the latest release, or checkout the latest code and build
it (not recommended).

onebir

unread,
Apr 18, 2009, 10:13:32 AM4/18/09
to ProfitPy Discuss
Thanks again - I can now open the GUI! Tomorrow I'll try to do
something with it...

Meanwhile, there seems to be a problem with the code generated by the
PyQt4 UI code generator.
For background, I first did as you suggested, then removed the ibpy
egg file from my python sys.path, & added the profitpy directory to
PYTHONPATH.

Then this happened:
---------------------------------------------------------------------------------------------------
o@o-laptop:/usr/lib/python2.5/site-packages/profitpy$ ./bin/
profit_workbench
Traceback (most recent call last):
<snip>
File "/usr/lib/python2.5/site-packages/profitpy/profit/lib/widgets/
ui_extendedshell.py", line 60
self.executeButton.setIcon(QtGui.QIcon("
^
SyntaxError: EOL while scanning single-quoted string
---------------------------------------------------------------------------------------------------
The offending statement was just split over over two lines:
self.executeButton.setIcon(QtGui.QIcon("
"))
(I thought breaking a statement within brackets was legal - apparently
not if it's a single-quoted string.)

I edited this to fit on one line, then got the same error here:
/usr/lib/python2.5/site-packages/profitpy/profit/workbench/widgets/
ui_main.py

This module contained multiple broken lines like the above, so I fixed
them. Edit>strategy designer & edit>settings produces these problems
in profitpy standard error - I'll try to fix them tomorrow.

Troy Melhase

unread,
Apr 18, 2009, 5:47:19 PM4/18/09
to profitpy...@googlegroups.com
> Thanks again - I can now open the GUI!  Tomorrow I'll try to do
> something with it...

Great.

> Meanwhile, there seems to be a problem with the code generated by the
> PyQt4 UI code generator.

Yes, some versions of SIP/PyQt4 generate bad .py files. Not much you
can do about it except manually fix the errors or upgrade your SIP and
PyQt4 packages.

onebir

unread,
Apr 19, 2009, 11:55:24 AM4/19/09
to ProfitPy Discuss
>> Meanwhile, there seems to be a problem with the code generated by the
>> PyQt4 UI code generator.

> Yes, some versions of SIP/PyQt4 generate bad .py files.  Not much you
> can do about it except manually fix the errors or upgrade your SIP and
> PyQt4 packages.

Well, I think I downloaded the latest available version of PyQt4. Not
sure about SIP - what's that?

But it occurred to me to write a script to fix the (systematic) errors
in the automatically generated code...

If anyone else gets the broken line errors I had above, hopefully now
you can just:
- drop the script in your profitpy directory (giving it name)
- cd to your profitpy directory
- & run with python NAME [I called fixprofitpy_ui.py but whatever
should do]

It seems to have fixed the problems with "Edit>strategy designer" &
"edit>settings". But I haven't tested it extensively, & I haven't
programmed much, so use at your own risk! Looks like it could save
quite a bit of manual editing though: it backs up the problem .py
files to .bup files, and created about 30 of these after I ran it.
I've only used it on ubuntu, but I used the os module so it *should*
work cross-platform. Here's the code, hope it's of use to someone:

#!/usr/bin/env python
import os, re

baseDir = os.getcwd()

def getfilelist(baseDir):
pathList = []
fileNameRE = re.compile(r'ui_\w+.py$')
for root, dirs, files in os.walk(baseDir):
if (root.find('widgets')> -1) and (root.find('.svn') == -1) :
fileList = ([f for f in files if fileNameRE.search(f)])
pathList.extend([os.path.join(root,f) for f in fileList])
return pathList

def fixbrokenlines(pathList):
brokenLineRE = re.compile('\(+\"?[^)]+$')
for path in pathList:
pn,fn = os.path.split(path)
bupPath = os.path.join(pn, (fn.split('.')[0] + '.bup'))
os.rename(path,bupPath)
bupfh = open(bupPath,'r')
pyfh = open(path, 'w')
partline = ''
for line in bupfh:
if brokenLineRE.search(line):
partline = line.rstrip()
continue
elif partline != '':
partline += line.lstrip()
pyfh.write(partline)
partline = ''
else:
pyfh.write(line)
bupfh.close()
pyfh.close()

pl = getfilelist(baseDir)
fixbrokenlines(pl)
print 'done'
Reply all
Reply to author
Forward
0 new messages