pyalgotrade
Python Algorithmic Trading Library
PyAlgoTrade - Algorithmic Trading python algorithmic trading library
The following code works fine in a python shell, displaying the content of the feed object:
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info(bar.getClose())
feed = yahoofeed.Feed()
feed.addBarsFromCSV("orcl","data/bistampTicker.csv")
myStrategy = MyStrategy(feed, "orcl")
myStrategy.run()
However, its execution in a Django views leads to the following error:
'function' object has no attribute 'BacktestingStrategy'
Where the BacktestingStrategy is a class defined in the __ init__.py file inside the strategy folder of the python module, inside the python path.
My understanding of the problem is that django doesn't read the __ init__.py file, thus not importing the module correctly (a pyalgotrade module).
Is there a way to tell Django to do so?
Thanks in advance and sorry for the noobish question.
Cheers
Source: (StackOverflow)
I want to backtest a trading strategy in pyalgotrade, but I’m having problems submitting the stoploss order.
In the documentation it states: Positions are higher level abstractions for placing orders. They are escentially a pair of entry-exit orders and allow to track returns and PnL easier that placing orders manually.
I enter the position with
myPosition = self.enterLong(self.__instrument, amount, True)
This basically opens a new position in shares and buys at market price, which by itself works.
I’d then expect to place the stop order with
myPosition.exitStop(stoplossValue, True)
… but this behaves really strange!
If the position isFilled, which is the case when the enterLong order was executed, then exitStop raises an assert error, because it seems to expect the order to be “isActive” (which conflicts isFilled).
When I call exitStop before the order isFilled (while isActive), the code generates no assert error, but the active order gets canceled immediately.
It absolutely makes no sense to call exitStop when the initial order hasn’t been executed yet. Or am I totally off the wall with my thinking?
Unfortunately the pyalgotrade tutorial strategies do not use any stoploss logic (which is bad).
Source: (StackOverflow)
I trying to write a Stochastic Oscillator in python using the list function in Pyalgotrade library.
Pyalgotrade library is a Python library for backtesting stock trading strategies. Let’s say you have an idea for a trading strategy and you’d like to evaluate it with historical data and see how it behaves. PyAlgoTrade allows you to do so with minimal effort.
The python code is like this:
from pyalgotrade.tools import yahoofinance
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import stoch
from pyalgotrade import dataseries
from pyalgotrade.technical import ma
from pyalgotrade import technical
from pyalgotrade.technical import highlow
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__stoch = stoch.StochasticOscillator(feed[instrument].getCloseDataSeries(),20, dSMAPeriod=3, maxLen=3)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info("%s %s" % (bar.getClose(), self.__stoch[-1]))
# Downdload then Load the yahoo feed from the CSV file
yahoofinance.download_daily_bars('AAPL', 2013, 'aapl.csv')
feed = yahoofeed.Feed()
feed.addBarsFromCSV("AAPL", "aapl.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "AAPL")
myStrategy.run()
The error is like this,including all the trace back.
Traceback (most recent call last):
File "/Users/johnhenry/Desktop/simple_strategy.py", line 47, in <module>
myStrategy.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/strategy/__init__.py", line 519, in run
self.__dispatcher.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/dispatcher.py", line 102, in run
eof, eventsDispatched = self.__dispatch()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/dispatcher.py", line 90, in __dispatch
if self.__dispatchSubject(subject, smallestDateTime):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/dispatcher.py", line 68, in __dispatchSubject
ret = subject.dispatch() is True
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/feed/__init__.py", line 101, in dispatch
dateTime, values = self.getNextValuesAndUpdateDS()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/feed/__init__.py", line 85, in getNextValuesAndUpdateDS
ds.appendWithDateTime(dateTime, value)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/dataseries/bards.py", line 49, in appendWithDateTime
self.__closeDS.appendWithDateTime(dateTime, value.getClose())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/dataseries/__init__.py", line 134, in appendWithDateTime
self.getNewValueEvent().emit(self, dateTime, value)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/observer.py", line 59, in emit
handler(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/technical/__init__.py", line 89, in __onNewValue
newValue = self.__eventWindow.getValue()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/technical/stoch.py", line 60, in getValue
lowestLow, highestHigh = get_low_high_values(self.__barWrapper, self.getValues())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/technical/stoch.py", line 42, in get_low_high_values
lowestLow = barWrapper.getLow(currBar)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyalgotrade/technical/stoch.py", line 31, in getLow
return bar_.getLow(self.__useAdjusted)
AttributeError: 'float' object has no attribute 'getLow'
Source: (StackOverflow)
I am trying to follow the introduction in PyAlgoTrade website to download the data from yahoo finance using the given code. But I always got an error.
Here is the website: http://gbeced.github.io/pyalgotrade/docs/v0.15/html/tutorial.html
...
Having said all that, the first thing that we’ll need to test our strategies is some data. Let’s use Oracle’s stock prices for year 2000, which we’ll download with the following command:
python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('orcl', 2000, 'orcl-2000.csv')"
After running this command, I got the error like below
>>> python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('orcl', 2000, 'orcl-2000.csv')"
SyntaxError: invalid syntax
Source: (StackOverflow)
Here is an example of SMA cross strategy, what is the reason we use self.setUseAdjustedValues(True)
and how does it works?
from pyalgotrade import strategy
from pyalgotrade.technical import ma
from pyalgotrade.technical import cross
class SMACrossOver(strategy.BacktestingStrategy):
def __init__(self, feed, instrument, smaPeriod):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
self.__position = None
# We'll use adjusted close values instead of regular close values.
self.setUseAdjustedValues(True)
self.__prices = feed[instrument].getPriceDataSeries()
self.__sma = ma.SMA(self.__prices, smaPeriod)
def getSMA(self):
return self.__sma
def onEnterCanceled(self, position):
self.__position = None
def onExitOk(self, position):
self.__position = None
def onExitCanceled(self, position):
# If the exit was canceled, re-submit it.
self.__position.exitMarket()
def onBars(self, bars):
# If a position was not opened, check if we should enter a long position.
if self.__position is None:
if cross.cross_above(self.__prices, self.__sma) > 0:
shares = int(self.getBroker().getCash() * 0.9 / bars[self.__instrument].getPrice())
# Enter a buy market order. The order is good till canceled.
self.__position = self.enterLong(self.__instrument, shares, True)
# Check if we have to exit the position.
elif not self.__position.exitActive() and cross.cross_below(self.__prices, self.__sma) > 0:
self.__position.exitMarket()
Source: (StackOverflow)
I wanted to implement my own strategy for backtesting but am unable to modify the code according to my needs
from pyalgotrade.tools import yahoofinance
yahoofinance.download_daily_bars('orcl', 2000, 'orcl-2000.csv')
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import ma
#class to create objects
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
# We want a 15 period SMA over the closing prices.
self.__sma = ma.SMA(feed[instrument].getCloseDataSeries(), 15)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info("%s %s" % (bar.getClose(), self.__sma[-1]))
# Load the yahoo feed from the CSV file
feed = yahoofeed.Feed()
feed.addBarsFromCSV("orcl", "orcl-2000.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "orcl")
myStrategy.run()
Source: (StackOverflow)
I trying to write a Ultimate Oscillator in python using the list function in Pyalgotrade library.
My code is below:
from pyalgotrade.tools import yahoofinance
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import stoch
from pyalgotrade import dataseries
from pyalgotrade.technical import ma
from pyalgotrade import technical
from pyalgotrade.technical import highlow
from pyalgotrade import bar
from pyalgotrade import talibext
import numpy
import talib
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
barDs = self.getFeed().getDataSeries("002389.SZ")
self.__ultosc = indicator.ULTOSC(barDs, 36)
bar = bars[self.__instrument]
self.info("%0.2f, %0.2f" % (bar.getClose(), self.__ultosc[-1]))
# Downdload then Load the yahoo feed from the CSV file
yahoofinance.download_daily_bars('002389.SZ', 2013, '002389.csv')
feed = yahoofeed.Feed()
feed.addBarsFromCSV("002389.SZ", "002389.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "002389.SZ")
myStrategy.run()
And I got the error like this:
File "/Users/johnhenry/Desktop/untitled.py", line 23, in onBars
self.__ultosc = indicator.ULTOSC(barDs, 36)
NameError: global name 'indicator' is not defined
The function can be found at http://gbeced.github.io/pyalgotrade/docs/v0.15/html/talib.html
Ultimate Oscillator:
pyalgotrade.talibext.indicator.ULTOSC(barDs, count, timeperiod1=-2147483648, timeperiod2=-2147483648, timeperiod3=-2147483648)
Source: (StackOverflow)
I am using optimizer in Pyalgotrade to run my strategy to find the best parameters. The message I get is this:
2015-04-09 19:33:35,545 broker.backtesting [DEBUG] Not enough cash to fill 600800 order [1681] for 888 share/s
2015-04-09 19:33:35,546 broker.backtesting [DEBUG] Not enough cash to fill 600800 order [1684] for 998 share/s
2015-04-09 19:33:35,547 server [INFO] Partial result 7160083.45 with parameters: ('600800', 4, 19) from worker-16216
2015-04-09 19:33:36,049 server [INFO] Best final result 7160083.45 with parameters: ('600800', 4, 19) from client worker-16216
This is just part of the message. You can see only for parameters ('600800', 4, 19)
and ('600800', 4, 19)
we have result, for other combination of parameters, I get the message : 546 broker.backtesting [DEBUG] Not enough cash to fill 600800 order [1684] for 998 share/s
.
I think this message means that I have created a buy order but I do not have enough cash to busy it. However, from my script below:
shares = self.getBroker().getShares(self.__instrument)
if bars[self.__instrument].getPrice() > up and shares == 0:
sharesToBuy = int(self.getBroker().getCash()/ bars[self.__instrument].getPrice())
self.marketOrder(self.__instrument, sharesToBuy)
if shares != 0 and bars[self.__instrument].getPrice() > up_stop:
self.marketOrder(self.__instrument, -1 * shares)
if shares != 0 and bars[self.__instrument].getPrice() < up:
self.marketOrder(self.__instrument, -1 * shares)
The logic of my strategy is that is the current price is larger than up, we buy, and if the current price is larger than up_stop or smaller than up after we buy, we sell. So from the code, there is no way that I will generate an order which I do not have enough cash to pay because the order is calculated by my current cash.
So where do I get wrong?
Source: (StackOverflow)
I have run into a problem where python is throwing a KeyError when trying to reference stock prices in pyalgotrade's onBars function. The interesting thing is that it depends which stocks you are trying to access. The following code does not work and throws the error:
from pyalgotrade import strategy
from pyalgotrade.tools import yahoofinance
from pyalgotrade.technical import ma
from pyalgotrade.stratanalyzer import returns
from pyalgotrade.stratanalyzer import sharpe
from pyalgotrade.utils import stats
from pyalgotrade.barfeed import yahoofeed
import os
import sys
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instruments):
strategy.BacktestingStrategy.__init__(self, feed, 1000)
self.__position = {}
self.__instruments = instruments
self.__sma20 = {}
self.__sma200 = {}
for inst in instruments:
price = feed[inst].getCloseDataSeries()
self.__sma20[inst] = ma.SMA(price, 20)
self.__sma200[inst] = ma.SMA(price, 200)
# We'll use adjusted close values instead of regular close values.
self.setUseAdjustedValues(True)
def onEnterOk(self, position):
execInfo = position.getEntryOrder().getExecutionInfo()
self.info("BUY " + str(position.getEntryOrder().getInstrument()) +" at " +str((execInfo.getPrice())) )
def onEnterCanceled(self, position):
execInfo = position.getEntryOrder().getExecutionInfo()
self.info("onEnterCanceled " + str(position.getEntryOrder().getInstrument()) +" at " +str((execInfo.getPrice())) )
def onBars(self, bars):
#print bars['AAD'].getClose()
for key in bars.keys():
print key
#sys.exit()
for inst in self.__instruments:
print inst
self.info(bars[inst].getClose())
print self.__sma20[inst][-1]
if self.__sma20[inst][-1] > self.__sma200[inst][-1] :
print "go long"
def run_strategy():
# Load the yahoo feed from the CSV file
stocks = ["ABP.AX","AGL.AX","ALL.AX","ALQ.AX","AMC.AX","AMP.AX","ANN.AX","ANZ.AX","APA.AX","APN.AX"]
#stocks = ['AAPL', 'IBM', 'MSFT', 'DOW', 'AXP','BA','CSCO','CVX','DD','DIS','GE','GS','HD','INTC','JNJ']
feed = yahoofinance.build_feed(stocks, 2003, 2014, "./DailyStockPrices")
# Evaluate the strategy with the feed.
myStrategy = MyStrategy(feed, stocks)
myStrategy.run()
print "Final portfolio value: $%.2f" % myStrategy.getBroker().getEquity()
run_strategy()
The stocks are Australian stocks and all valid. The yahoofeed module downloads them. If I comment out the line beginning with stocks = and uncomment the line below to use US stocks it works perfectly.
My first thought was full stops in the stock codes but if you run it, it prints out the contents of bars.keys() and this keeps changing which appears to be the cause of the issue. It eventually errors on one that doesn't exist but why the contents change on every bar is beyond me.
Can anyone explain or help fix this phenomena? I very much like Pyalgotrade and have been looking at Zipline as an alternative but it's too slow.
Source: (StackOverflow)
So, I updated PyAlgoTrade to 0.15, and now the sample code works. I did not investigate the cause of the error yet, but can safely say that 0.15 works as expected.
I have been googling for a while now, but am still unable to find a solution, or even determine the problem, honestly.
My installation of Python and Pyalgotrade is correct, as verified by the successful imports.
Nonetheless, I can't manage to run the example code in the tutorial, it always throws:
AttributeError: MyStrategy instance has no attribute 'info'
Here's the example code:
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info(bar.getClose())
# Load the yahoo feed from the CSV file
feed = yahoofeed.Feed()
feed.addBarsFromCSV("orcl", "orcl-2000.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "orcl")
myStrategy.run()
And the iPython Notebook output:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-f786d1b471f7> in <module>()
18 # Evaluate the strategy with the feed's bars.
19 myStrategy = MyStrategy(feed, "orcl")
---> 20 myStrategy.run()
/usr/local/lib/python2.7/site-packages/pyalgotrade/strategy/__init__.pyc in run(self)
398 self.onStart()
399
--> 400 self.__dispatcher.run()
401
402 if self.__feed.getCurrentBars() != None:
/usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in run(self)
139 subject.start()
140
--> 141 while not self.__stopped and self.__dispatch():
142 pass
143 finally:
/usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in __dispatch(self)
131 nextDateTime = subject.peekDateTime()
132 if nextDateTime == None or nextDateTime == smallestDateTime:
--> 133 subject.dispatch()
134 return ret
135
/usr/local/lib/python2.7/site-packages/pyalgotrade/feed/__init__.pyc in dispatch(self)
95 dateTime, values = self.getNextValuesAndUpdateDS()
96 if dateTime != None:
---> 97 self.__event.emit(dateTime, values)
98
99 def getKeys(self):
/usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in emit(self, *parameters)
51 self.__emitting = True
52 for handler in self.__handlers:
---> 53 handler(*parameters)
54 self.__emitting = False
55 self.__applyChanges()
/usr/local/lib/python2.7/site-packages/pyalgotrade/strategy/__init__.pyc in __onBars(self, dateTime, bars)
386
387 # 1: Let the strategy process current bars and place orders.
--> 388 self.onBars(bars)
389
390 # 2: Place the necessary orders for positions marked to exit on session close.
<ipython-input-1-f786d1b471f7> in onBars(self, bars)
10 def onBars(self, bars):
11 bar = bars[self.__instrument]
---> 12 self.info(bar.getClose())
13
14 # Load the yahoo feed from the CSV file
AttributeError: MyStrategy instance has no attribute 'info'
Has anyone at least a hint on what the problem could be?
Source: (StackOverflow)
I got an import error while I am running a simple python written trading strategy in Pyalgotrade.
from pyalgotrade.tools import yahoofinance
yahoofinance.download_daily_bars('orcl', 2000, 'orcl-2000.csv')
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import ma
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
# We want a 15 period SMA over the closing prices.
self.__sma = ma.SMA(feed[instrument].getCloseDataSeries(), 15)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info("%s %s" % (bar.getClose(), self.__sma[-1]))
# Load the yahoo feed from the CSV file
feed = yahoofeed.Feed()
feed.addBarsFromCSV("orcl", "orcl-2000.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "orcl")
myStrategy.run()
And the error is showed as below.
>>>Traceback (most recent call last):
File "/Users/johnhenry/Desktop/pyalgotrade2.py", line 1, in <module>
from pyalgotrade import strategy
File "/Users/johnhenry/Desktop/pyalgotrade.py", line 1, in <module>
from pyalgotrade import strategy
ImportError: cannot import name strategy
I am sure I have this library called pyalgotrade.
Source: (StackOverflow)
I trying to write a Stochcastic Oscillator in python using the list function in Pyalgotrade library.
My code is below:
from pyalgotrade.tools import yahoofinance
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import stoch
from pyalgotrade import dataseries
from pyalgotrade.technical import ma
from pyalgotrade import technical
from pyalgotrade.technical import highlow
from pyalgotrade import bar
from pyalgotrade.talibext import indicator
import numpy
import talib
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
def onBars(self, bars):
barDs = self.getFeed().getDataSeries("002389.SZ")
self.__stoch = indicator.STOCH(barDs, 20, 3, 3)
bar = bars[self.__instrument]
self.info("%0.2f, %0.2f" % (bar.getClose(), self.__stoch[-1]))
# Downdload then Load the yahoo feed from the CSV file
yahoofinance.download_daily_bars('002389.SZ', 2013, '002389.csv')
feed = yahoofeed.Feed()
feed.addBarsFromCSV("002389.SZ", "002389.csv")
# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "002389.SZ")
myStrategy.run()
And I got the error like this:
File "/Users/johnhenry/Desktop/simple_strategy.py", line 46, in onBars
self.info("%0.2f, %0.2f" % (bar.getClose(), self.__stoch[-1]))
TypeError: float argument required, not numpy.ndarray
Stochastic:
pyalgotrade.talibext.indicator.STOCH(barDs, count, fastk_period=-2147483648, slowk_period=-2147483648, slowk_matype=0, slowd_period=-2147483648, slowd_matype=0)
Source: (StackOverflow)
On Mac OS X Mountain Lion, I try
import numpy as np
import os
import statsmodels.api as sm
I get this error:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/idf/PycharmProjects/PyAlgoTrade/GoldvsMiners.py
Traceback (most recent call last):
File "/Users/idf/PycharmProjects/PyAlgoTrade/GoldvsMiners.py", line 9, in <module>
import statsmodels.api as sm
File "/Library/Python/2.7/site-packages/statsmodels-0.0.0-py2.7-macosx-10.8-intel.egg/statsmodels/api.py", line 1, in <module>
import iolib, datasets, tools
ImportError: No module named iolib
If I add
import sys
print("=======")
print sys.path
print("=======")
I get
=======
['/Users/idf/PycharmProjects/PyAlgoTrade', '/Library/Python/2.7/site-packages/pytz-2013b-py2.7.egg', '/Library/Python/2.7/site-packages/statsmodels-0.0.0-py2.7-macosx-10.8-intel.egg', '/Library/Python/2.7/site-packages/pip-1.4-py2.7.egg', '/Users/idf/PycharmProjects/PyAlgoTrade', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
=======
I have tried searching the net, but I am stuck on this one. Any ideas?
Source: (StackOverflow)