[proFit-list] problem with Python

Davide Guarisco guarisco at sbcglobal.net
Wed Feb 12 00:21:58 CST 2014


I have run into this problem myself (I like to use the Anaconda distribution).

In theory, you should be able to tell pro Fit your “Path to Python Library” in Preferences>Scripting. Then pro Fit should be able to import everything in that path’s "site-packages” folder. 

This works for some versions of Python but not for others. 

For example, the default value of "Path to Python Library" is: /Library/Frameworks/Python.framework/Versions/2.6/Python
Any package that you install there, you should be able to import into pro Fit. 

If you install the python.org's Python distribution for, say, 2.7, the Python Library path is now: /Library/Frameworks/Python.framework/Versions/2.7/Python. If you tell pro Fit to use it, it accepts it. 

This works with no issues. For example, I am able to import numpy. To test where the imported package file actually is, you can use Python’s construct __file__.

Example script:

## script test
import numpy as np
print np.__file__

On my system, this outputs: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.pyc
(Of course, for this to work you have to have numpy installed in the 2.7 hierarchy). 

However, things do not work for Anaconda. The pro Fit developers explained to me that this is because that version is 64 bits, while pro Fit is a 32 bit application. This has the undesirably side effect that I have to maintain two Python environments: my preferred Anaconda (with a lot of packages installed) and the “official” Python 2.x (or 3.x) for use with pro Fit. 

Hopefully in the future pro Fit will make the jump to 64 bits and will be able to accept the Anaconda version of Python and coexist happily. 

Now, just for fun, I tried installing pandas in my 2.7 installation. For this, I opened terminal and typed:

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip install pandas
(remember, you want to run the pip inside the 2.7 hierarchy, not inside EPD)

After a lot of gibberish you should see: Successfully installed pandas python-dateutil putz six
(This means that pandas and its dependencies were installed). 

After that, I was able to use pandas in IDLE:
>>> import pandas as pd
>>> dates = pd.date_range('20140211',periods=6)
>>> dates
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-02-11, ..., 2014-02-16]
Length: 6, Freq: D, Timezone: None

Tried the same thing in a pro Fit script and it worked. 

Hope this helps.

Davide





On Feb 11, 2014, at 10:15:35, Harbinson, Jeremy <jeremy.harbinson at wur.nl> wrote:

> --===============0938751691159663979==
> Content-Language: en-US
> Content-Type: multipart/alternative;
> 	boundary="_000_7A56777A4680B443B8F1EF7BE60A1CEC16AC131FSCOMP0934wurnet_"
> 
> --_000_7A56777A4680B443B8F1EF7BE60A1CEC16AC131FSCOMP0934wurnet_
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: quoted-printable
> 
> Hi,
> You are correct - there was a Python version mis-match; the Profit default =
> was Python 2.6 and I had pandas in my 2.7 folder. I changed this, but panda=
> s still would not load, though I can load other modules
> 
> Using sys.modules I have gotten the paths of the modules I have loaded into=
> Python 2.7 running in Terminal - numpy and pandas in this case are in the =
> Enthought Python 2.7 folder. I can load numpy into a Profit script and it r=
> uns, while pandas does not. Up to now, however, I have not been able to get=
> a report of the path of the numpy that is being loaded in the Profit scrip=
> t.
> All the best,
> Jeremy Harbinson
> 
> From: proFit-list [mailto:profit-list-bounces at quantum-soft.com] On Behalf O=
> f Chris Lee
> Sent: dinsdag 11 februari 2014 16:48
> To: all things about pro Fit
> Subject: Re: [proFit-list] problem with Python
> 
> It sounds (and you have probably checked this) like you are using the wrong=
> version of python.
> 
> On 11 Feb 2014 (W: 7), at 16:46, Harbinson, Jeremy <Jeremy.Harbinson at wur.nl=
> <mailto:Jeremy.Harbinson at wur.nl>> wrote:
> 
> 
> Hi,
> I am not able to import pandas into a Python function. I am using OSX 10.8.=
> 4, I have the Enthought Python Distribution installed (1.3.0.1715) and my P=
> roFit is 6.2.11.
> Pandas can be imported into Python running in a terminal and works there, s=
> o it seems to be functioning in a general sense (and it works in Enthought'=
> s own python gui). I needed to update a function that used PyDataFrame, whi=
> ch no longer works, and pandas seemed to be an easy alternative, but the li=
> ne:
> 
> import pandas as pd
> 
> gets the response that there is 'no module called pandas' - even using sys.=
> path.append to add the pandas path (or what I think is the path) did not wo=
> rk. Any suggestions? My guess is that this is a basic, silly mistake on my =
> part, so don't spare me the obvious!
> All the best,
> Jeremy Harbinson
> _______________________________________________
> proFit-list mailing list
> proFit-list at quantum-soft.com<mailto:proFit-list at quantum-soft.com>
> http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com
> 
> 
> --_000_7A56777A4680B443B8F1EF7BE60A1CEC16AC131FSCOMP0934wurnet_
> Content-Type: text/html; charset="us-ascii"
> Content-Transfer-Encoding: quoted-printable
> 
> <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
> osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
> xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
> //www.w3.org/TR/REC-html40">
> <head>
> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>> 
> <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
> <style><!--
> /* Font Definitions */
> @font-face
> 	{font-family:Calibri;
> 	panose-1:2 15 5 2 2 2 4 3 2 4;}
> @font-face
> 	{font-family:Tahoma;
> 	panose-1:2 11 6 4 3 5 4 4 2 4;}
> @font-face
> 	{font-family:Verdana;
> 	panose-1:2 11 6 4 3 5 4 4 2 4;}
> /* Style Definitions */
> p.MsoNormal, li.MsoNormal, div.MsoNormal
> 	{margin:0cm;
> 	margin-bottom:.0001pt;
> 	font-size:11.0pt;
> 	font-family:"Calibri","sans-serif";
> 	mso-fareast-language:EN-US;}
> a:link, span.MsoHyperlink
> 	{mso-style-priority:99;
> 	color:blue;
> 	text-decoration:underline;}
> a:visited, span.MsoHyperlinkFollowed
> 	{mso-style-priority:99;
> 	color:purple;
> 	text-decoration:underline;}
> span.EmailStyle17
> 	{mso-style-type:personal;
> 	font-family:"Verdana","sans-serif";
> 	color:windowtext;}
> span.EmailStyle18
> 	{mso-style-type:personal-reply;
> 	font-family:"Verdana","sans-serif";
> 	color:#1F497D;}
> .MsoChpDefault
> 	{mso-style-type:export-only;
> 	font-size:10.0pt;}
> @page WordSection1
> 	{size:612.0pt 792.0pt;
> 	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
> div.WordSection1
> 	{page:WordSection1;}
> --></style><!--[if gte mso 9]><xml>
> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
> </xml><![endif]--><!--[if gte mso 9]><xml>
> <o:shapelayout v:ext=3D"edit">
> <o:idmap v:ext=3D"edit" data=3D"1" />
> </o:shapelayout></xml><![endif]-->
> </head>
> <body lang=3D"EN-GB" link=3D"blue" vlink=3D"purple">
> <div class=3D"WordSection1">
> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ve=
> rdana","sans-serif";color:#1F497D">Hi,<o:p></o:p></span></p>
> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ve=
> rdana","sans-serif";color:#1F497D">You are correct – t=
> here was a Python version mis-match; the Profit default was Python 2.6 and =
> I had pandas in my 2.7 folder. I changed this, but pandas still
> would not load, though I can load other modules<o:p></o:p></span></p>
> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ve=
> rdana","sans-serif";color:#1F497D"><o:p> </o:p></span><=
> /p>
> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ve=
> rdana","sans-serif";color:#1F497D">Using sys.modules I have =
> gotten the paths of the modules I have loaded into




More information about the proFit-list mailing list