您的位置:首页 > 编程语言 > Python开发

Mac 下配置 Python 开发环境

2016-03-08 20:26 886 查看
➜  ~  sudo brew install python3
==> Downloading https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz Already downloaded: /Library/Caches/Homebrew/python3-3.5.1.tar.xz
==> Downloading https://bugs.python.org/file40478/xcode-stubs.diff Already downloaded: /Library/Caches/Homebrew/python3--patch-029cc0dc72b1bcf4ddc5f913cc4a3fd970378073c6355921891f041aca2f8b12.diff
==> Patching
patching file Lib/distutils/ccompiler.py
patching file Lib/distutils/unixccompiler.py
==> ./configure --prefix=/usr/local/Cellar/python3/3.5.1 --enable-ipv6 --dataroo
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.5.1
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.5.1/sh
==> Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools- Already downloaded: /Library/Caches/Homebrew/python3--setuptools-18.3.1.tar.gz
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz Already downloaded: /Library/Caches/Homebrew/python3--pip-7.1.2.tar.gz
==> Downloading https://pypi.python.org/packages/source/w/wheel/wheel-0.26.0.tar Already downloaded: /Library/Caches/Homebrew/python3--wheel-0.26.0.tar.gz
==> /usr/local/Cellar/python3/3.5.1/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.5.1/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.5.1/bin/python3 -s setup.py --no-user-cfg instal
==> Caveats
Pip and setuptools have been installed. To update them
pip3 install --upgrade pip setuptools

You can install Python packages with
pip3 install <package>

They will install into the site-package directory
/usr/local/lib/python3.5/site-packages

See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 
.app bundles were installed.
Run `brew linkapps python3` to symlink these to /Applications.
==> Summary
🍺  /usr/local/Cellar/python3/3.5.1: 7,619 files, 106.1M, built in 2 minutes 7 seconds
➜  ~


使用了几天sublimetext3,后面尝试了pycharm 秒杀一切 !!!

#import logging as logger
import sqlalchemy
import tushare as ts
from sqlalchemy import create_engine

# engine = create_engine('mysql://root:xxx@127.0.0.1/xxx?charset=utf8')
# df = ts.get_tick_data('600848', date='2016-03-17')
# df.to_sql('tick_data',engine,if_exists='replace')

# engine = create_engine('postgresql://postgres:xxx@xxx.xxx.185.215:5432/xxx')
# stocks.to_sql('tick_data',engine)
# df = ts.get_tick_data('600848', date='2014-12-22')
# engine = create_engine('mysql://xxx:xxx@xxx.xxx.185.215/xxx?charset=utf8')

# https://github.com/PyMySQL/PyMySQL engine = create_engine('mysql+pymysql://xxx:xxx.@xxx.xxx.185.215/xxx?charset=utf8')

# engine = create_engine('postgresql+pg8000://xxx:xxx@xxx.xxx.185.215:5432/xxx', client_encoding='utf8')

# 追加数据到现有表
# df.to_sql('tick_data',engine,if_exists='append')

#获得基本面数据
stocks=ts.get_stock_basics()
# 存入数据库
stocks.to_sql('stock_basics', engine, if_exists='replace', dtype=dict(code=sqlalchemy.VARCHAR(length=10),
name=sqlalchemy.VARCHAR(length=20),
industry=sqlalchemy.VARCHAR(length=20),
area=sqlalchemy.VARCHAR(length=10),
pe=sqlalchemy.DECIMAL(18, 2),
outstanding=sqlalchemy.DECIMAL(18, 2),
totals=sqlalchemy.DECIMAL(18, 2),
totalAssets=sqlalchemy.DECIMAL(18, 2),
fixedAssets=sqlalchemy.DECIMAL(18, 2),
reserved=sqlalchemy.DECIMAL(18, 2),
reservedPerShare=sqlalchemy.DECIMAL(18, 2),
eps=sqlalchemy.DECIMAL(18, 2),
bvps=sqlalchemy.DECIMAL(18, 2),
pb=sqlalchemy.DECIMAL(18, 2),
timeToMarket=sqlalchemy.DECIMAL(18, 2)))
#获取日k线数据
for code, row in stocks.iterrows():
his_data=ts.get_hist_data(code,start='2016-01-01',end='2016-03-19',retry_count=10)
his_data['code']=code
his_data.to_sql('his_data',engine, dtype=dict(code=sqlalchemy.VARCHAR(length=10),date= sqlalchemy.DATE()))

http://www.sublimetext.com/ https://packagecontrol.io/ http://www.jetbrains.com/pycharm/ http://python3-cookbook.readthedocs.org/ http://codingpy.com/books/thinkpython2/ http://scrapy-chs.readthedocs.org/zh_CN/latest/intro/tutorial.html http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: