ubuntu10.10升级后进不了桌面的解决方法

显卡驱动无法加载是因为X Server升级到了1.9,而最新的n卡驱动只支持到1.8,它检测到ABI不符合就会拒绝加载。
解决方法:在/etc/X11/xorg.conf添加:
代码:
Section "ServerFlags"
    Option "ignoreABI" "True"
EndSection

发表在 未分类 | 发表评论

Matplot-python用法速查

典型的Matplot例子

import numpy as np
import matplotlib.pyplot as plt

def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)

t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), ‘bo’, t2, f(t2), ‘k’)

plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), ‘r–’)

题目,坐标轴设置

最简单的就是通过title,xlabel和ylabel设置,比如

xlabel(”xxxx”, fontsize=18, color=”red”)

这里title是某个axis的title,如果希望整个figure有title,那么需要用suptitle() 函数,用法和title是一样的。
x和y轴的范围设定是通过

plt.axis([0, 6, 0, 20])

这就是表示x轴是0到6,y轴是0到20。也可以用xlim和ylim单独控制,比如

ylim( ymin, ymax )

当然还可以用yscale和xscale指定坐标轴的scale类型,分别是‘linear’ | ‘log’ | ‘symlog’,比如

xscale("log")

还可以通过yaxis.grid和xaxis.grid控制怎么显示网格,是否显示网格。grid的函数是这样的

grid(self, b=None, which=’major’, **kwargs)
Set the axis grid on or off; b is a boolean use which =
‘major’ | ‘minor’ to set the grid for major or minor ticks

如果用yaxis.grid (false),就表示不用显示y轴方向的网格。

有时候我们需要在坐标轴上放文字,比如在x轴上放置月份名称之类,这就需要xticks函数。其用法是比如

xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )

这里,第一个参数表示放置位置,第二个是放置内容。

设置曲线特征

lines = plt.plot(x1, y1, x2, y2)
# use keyword args
plt.setp(lines, color='r', linewidth=2.0)
# or matlab style string value pairs
plt.setp(lines, 'color', 'r', 'linewidth', 2.0)

如果希望知道有哪些属性可以指定,可以传递对象给setp()函数,比如

In [69]: lines = plt.plot([1,2,3])

In [70]: plt.setp(lines)
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
…snip

具体能控制的属性参见这里

文字处理
text()命令可以被用来放置文字在绝对坐标轴上,用法是

text(60, .025, r'$mu=100, sigma=15$', horizontalalignment='left', verticalalignment='top')

放置的东西前面加个r表示包括数学公式。具体能控制的属性可以参见属性列表。具体的数学公式和符号的表达方式参见这里

这只是放置文字,还有一种需求是要求放置文字标注比如这种图:

这时候就要用到anotate()函数了,用法大概是这样的,

plt.annotate('local max', xy=(2, 1), xytext=(3, 1.5), arrowprops=dict(facecolor='black', shrink=0.05), )

第一个参数是要放置的文字,第二个参数是要指向的坐标,第三个是放置文字的坐标,最后一个是箭头属性。相关属性设置参见这里

对于经常写公式的人来讲,可能latex的格式会感觉更加常用一点。这时候,可以在放置text之前先用

rc('text', usetex=True)

然后与文字有关的地方都用r”"来引用,比如

title(r"TeX is Number $displaystylesum_{n=1}^inftyfrac{-e^{ipi}}{2^n}$!",
fontsize=16, color='r')

画函数

plt.plot最简单的形式就是take一组列表数据

plt.plot([1,2,3])

此时plot自动将其认为是y轴的数据,x轴数据自动分配,相当于是

plt.plot([0,1,2],[1,2,3])

也就是说,对于plot,标准形式是

plt.plot([1,2,3,4], [1,4,9,16])

当然,后面可以跟控制表示形式的参数,比如

plt.plot([1,2,3,4], [1,4,9,16], ‘ro’)

就表示用红色点表示,而不是直线。参数默认是’b-’,表示蓝色直线。
plot还支持同时在一张图里面绘制多个图形,比如


import matplotlib.pyplot as plt
plt.plot(x1, y1, 'r--', x2, y2, 'bs', x3, y3, 'g^')

就可以用不同的形式绘制三条曲线。

画子图

用plt.subplot(xxx),第一个数字表示numrows,第二个表示numcols,第三个表示fignum。fignum的数量最高也就是numrows乘以numcols。

如果是想产生多个图,每个图包含几个子图,那用figure()来控制图的数量。

画直方图

用函数

hist(x, bins=10, range=None, normed=False, cumulative=False,
bottom=None, histtype='bar', align='mid',
orientation='vertical', rwidth=None, log=False, **kwargs)

具体用法参加这里

画分布图
函数

scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0, linewidths=None,
verts=None, **kwargs)

具体参数看这里,唯一一个不是很确定的是s的取值,我曾经估计是s值要和x和y的列表长度一样,也就是大概是点的个数?但具体画的时候发现不是这样,点的个数取决于x和y的列表长度。有待研究。

画Box Plot图
用matplot画Box Plot不知道有多方便,直接用函数

boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None)

你直接把一组数用x送进去,出来就是Box图。如果你想一个图表示多个Box,也很简单,让xappend多个list,出来的就是这些list的box图。一个例子如下

for attribute in iris[type].keys():
list = iris[type][attribute]
data.append(list)
subplot(2,2,count)
title(”Boxplot of %s” % type, fontsize=18, color=”red”)
xticks(arange(5),(”",”Sepal len”,”Sepal wid”,”Petal len”,”Petal wid”))
ylabel(”Value”)
boxplot(data,0,’gd’)

发表在 未分类 | 发表评论

配黑苹果电脑

技嘉X58 UD3R+i7 920,6G内存


产品编码 产品名称 产品型号 保三年报价
MB871CH/A Mac Pro CPU:2.66GHz Intel Xeon;内存:3GB 1066MHz DDR3 ECC DIMM;硬盘:640GB SATA;显卡:NVIDIA GeForce GT 120, 512MB GDDR3 显存;光驱:18x SuperDrive 21690
MB535CH/A CPU:2×2.26GHz Intel Xeon;内存:6GB 1066MHz DDR3 ECC DIMM;硬盘:640GB SATA;显卡:NVIDIA GeForce GT 120, 512MB GDDR3 显存;光驱:18x SuperDrive 27690


别人说的都是废话,看配置。肯定能装上苹果系统而且稳定。(我的系统主要用途是做非编)
一、硬件配置:

1、主板:华硕Z8NA-D6C(市场价约 2700元)。

2、CPU:INTEL志强5520 双C (市场价约 2700元/颗)。(预算少可以先上一颗CPU)

3、内存:金士顿 DDR3 2G/1066*6条 (市场价约 200元/条)。

4、显卡:蓝宝 HD4870 521M黄金版 (市场价约 1000元)。

上边的价格是一年前的价格了。

mac10.6.4  
  i7 920
 GA-X58A-UD7
 蓝宝5870
   2G*6 1333
  希捷1T*2


i7930 技嘉EX58-UD3L OCZ4G套装 500G硬盘 索泰9800GT 银欣SilverStone Fortress2机箱 海盗船550w电源  三星P2370显示器
[GUID]i7 920 GA-EX58/UD3R DDRIII/2000 2GX3 GTX 285 mac os x10.6.4 

主機板:技嘉 GA-EX58-UD5(X58-ICH10R)
處理器:英特爾 i7 930 2.8G(LGA1366)
顯示卡:艾爾莎 960GT 512B3 2DT RH(NVIDIA)
音效卡:瑞昱 ALC889A
網路卡:瑞昱 RTL8111D

主板:ASUS DSGC-DW服务器主板 3100RMB
CPU:Intel Xeon 5355 双四核处理器 2100RMB
显卡:XFX 9800GTX 512M独立显卡 960RMB
内存:DDR2 FDB 2GB*2 750RMB
硬盘:SATA II 500G  370RMB
光驱:先锋SATA DVD刻录 190RMB
机箱:服务器机箱 350RMB
电源:500W额定电源 580RMB      主机合计:10500 RMB


1
、主板:华硕Z8NA-D6C(市场价约 2700元)。


2、CPU:INTEL志强5550 双C (市场价约 2700元/颗)。


3、内存:金士顿 DDR3 2G/1066*6条 (市场价约 200元/条)。


4、显卡:蓝宝 HD4870 521M黄金版 (市场价约 1000元)。

2、开始安装苹果系统:

设置光驱启动放入光盘,引导后提示按F8.

按F8后输入: -V
CPUS=1
BUSRATIO=20。(这个论坛上有)


联想3000G430  最高配置的   无线网卡  4310, 9300GS显卡,  2G内存,    成本3600样子.升级bios可以刷374字节,免费XP.vista.win7   完美黑苹果.


cpu:E5200双核或者4核的Q8200(选哪个看你预算)
主板:技嘉P43或者P45都可以(有人说P43以下的也可以,个人觉得有时候P43以下主板AHCI麻烦一点)
光驱:SATA光驱(IDE的要驱动)
内存:金士顿2G(个人推荐,理由是终身保固)
显卡:9600GT吧(因为觉得现在这个卡性价比不错,比9400好太多。而且白菜价)
硬盘:建议希捷SATA(其实我真觉得即使我不说你也不会买个IDE的回来)

最后,告诉你我的安装方法:光盘安装,制作一个efi引导盘。引导原版雪豹光盘,把硬盘格式成GUID分区表,直接安装,到最后显示安装失败,不必理会,直接重启,再用efi引导装好的雪豹。安装MYhack。重启,显卡和网卡就搞定了。接着安装一个voodoo万能声卡驱动,重启就有声音了。你的雪豹就完成了

至于想要双系统的话,建议你弄两块硬盘吧,个人觉得现在所有硬件里,硬盘够廉价的了吧。而且双硬盘装双系统灰常简单,不折腾,即使一个硬盘挂了,另一个也可以正常工作吧。而且myhack可以直接引导另一个硬盘上的window。简单的要命

该说的就这么多了,建议楼主多看看帖子,善用搜索



I7 920                            1900
X58 UD3R                      1200
6G DDR3 1600三通道       1300
GTX260+                        1400
硬盘光驱机箱电源     1000-2000


台式:CPU Q8200
显卡:华硕GTX260+
主板:技嘉EP45T-UD3R
内存:4GB DDR3 1333
500G硬盘。10.6.4完美~


装hackintosh,最主要的就是主板和显卡的搭配,其他的东西,除了无线网卡基本上都兼容。
http://www.insanelymac.com/forum/index.php?s=f53fa300362654d69f91344ebc8be383&showtopic=148416
老外用的是ASUS P5N7A这个板子,用的mcp7a芯片组,集成9300/9400显卡,和macbook和macmini差不多
我自己就是看到上面的这个帖子才决定用P5N7A的,装原版SL100%完美,不是99.9%的完美,就是100%的完美。


技嘉P43-ES3G,INTEL E6300,DDRII800 2G*2,N9500GT,WD500G
加19显示器差不多3800大洋
完美安装10.6.3原版,驱动全部完美


主板: 技嘉 EP45-UD3L
cpu:ntel® Core(TM)2 Quad CPU Q8200
内存:金士顿 DDR2 800 2G X 4
显卡:华硕 9600gso 512M
硬盘: 希捷1T


GA-EP45-UD3L
Core2 Duo Q8300
9800GT 512M
2*2G 内存

刷bios后完美


用dell  的 490或690  准系统    490大概 1300元  690大概1600元  (含机箱 电源 主板)
四核 至强XEON 5355 * 2块     1400元*2  
FB-ECC全缓冲内存8G              350元*4



CPU i7 930 2.8G Hz 8MB缓存 4.8GT/QPI 三年质保
主板 X58芯片组 三年质保
显卡 GTS250 1G显存 超静音风扇 双DVI 接口 三年质保
内存 6G DDR3 1333 (2GX3)附带散热片套装 终身质保
硬盘 1T 西数硬盘(最高性能的黑板) 三年质保

DVD刻录机

先锋DVD刻录机 一年质保
电源 额定400W 电源 三年质保
机箱 酷冷开拓者 一年质保



CPU:i7 920  MOBO:MSI X58Pro-E 
显卡:索泰9800GT F1 ; 内存:3x2G
硬盘:Seagate 1T SATAII + WD320G SATAII
光驱:Pioneer DVD-RW SATA;
QE/CI/网卡/声卡/休眠/关机/重启–OK

处理器    Intel Core i7 920 ( 2.67GHz 四核超线程 )
主   板    ASUS P6T ( Intel X58 芯片组 + CH10 )
内   存    GeIL 2×2 GB ( DDR3 1333 MHz 双通道 )
硬   盘    Seagate ST3500320AS ( 500GB S-ATA )
显   卡    NVIDIA Geforce GTX 295 ( 896MB )
光   驱    PHILIPS SPD2417T ( DVDRW 刻录 )
声   卡    ALC1200  ICH10       网   卡    RTL8111C


MAC10.6.4+WIN7
CPU:i7 950 ES版
主板:华硕P6T
内存:金士顿 2GX2 1333
显卡:9800GT 
升级到10.6.4,睡眠,关机重启,CPU,显卡,声卡,网卡辨识全部完美。CPU超频3.8GHz跑分11500,不超频9600.

CPU intel e8500               主板 技嘉ep43-ud3l  BIOS F9
内存 芝奇1000-4gbpq        显卡 索泰 8800gt 512M
主硬盘希捷 320g              次硬盘 西数绿盘 640g         
WINDOWS 7 64(硬刷BIOS),雪豹10.6.3(个人认为完美)


发表在 未分类 | 发表评论

安装readline库,解决python命令行无法输入中文问题


curl ftp://ftp.gnu.org/gnu/readline/readline-5.0.tar.gz | tar xfz - cd readline-5.0 ./configure cd shlib sed -e 's/-dynamic/-dynamiclib/' Makefile > Makefile.good mv Makefile.good Makefile cd .. make && sudo make install sudo rm /usr/lib/libreadline* sudo ln -s /usr/local/lib/libreadline* /usr/lib/ I got those from here, just FYI: http://tech.rufy.com/articles/2005/05/01/complete-fix-for-ruby-on-mac- os-x-10-4-tiger

发表在 未分类 | 发表评论

mac源码安装python


安裝 Python 2.6

下载:http://www.python.org/download/releases/2.6.5/
$ tar zxvf ~/Desktop/Python-3.0.tgz.tar
$ cd Python-2.6.5
$ sudo ./configure –with-universal-archs=intel –enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk –enable-framework
$ make
$ sudo make frameworkinstall
$ cd /Library/Frameworks/Python.framework/Versions/
$ sudo rm Current
$ sudo ln -s 2.4 Current

发表在 未分类 | 发表评论

Deploy PyQt Applications on Mac OS X with PyInstaller!


Deploy PyQt Applications on Mac OS X with PyInstaller!

xiao

The interweb seem to incline onpy2app when it come to deploying applications on mac. I’ve tried to make a single deployable .app file for my application for a long time trying to follow these instructions from ars technica. I’m not a hacker and just want to produce a deployable usable application for others to use. And it seems py2app from MacPorts wasn’t able to surmount the Snow Leopard’s 64-bit compatibility issue.

And then, I was slacking off while studying for my final and out of nowhere I found PyInstaller‘s explicit support for PyQt and its recent support for the mac. And after trying, almost everything works out without much of a kink. Credit goes to ChrisWayg who produced an amazingly complete and up-to-date set of instructions to follow. I’m merely telling how my application did using his instructions (April 2010) and hopefully doing my part to draw more attention to the excellent PyInstaller.

My Application

A PyQt application to help photographers apply custom watermarks in a manual but in an assisted way.

Uses:

  • PIL 1.1.7
  • Qt4 4.6.2
  • PyQt4 4.7.2
  • SIP 4.10.1

All from MacPorts on Python 2.6.5, OSX 10.6.3.

Prepare PyInstaller

PyInstaller is kinda special in that it’s not installed anywhere. It’s just a bunch of Python scripts that work on stuff in place. While you’re at it, read the manual.

svn co http://svn.pyinstaller.org/trunk ~/PyInstaller

Or put it somewhere you want.

Then you need to build the bootloaders. If you’re making PyQt applications, you probably have XCode already. Anyway, you need it.

cd source/linux
python Make.py
make
cd ..
python Configure.py

Making your Application

So far, PyInstaller has a problem of not showing your application at the front when you run it. You can fix it in your own code by adding

form.raise_()

right after

form.show()

with “form” being whatever you called your instance of MainWindow().

Like with py2app, you gotta first make a “spec file”.

python Makespec.py --onefile /path/to/YourApplication.py

This will make a YourApplication/YourApplication.spec file in your PyInstaller folder.
To make it work on mac, add

import sys
if sys.platform.startswith("darwin"):
    app = BUNDLE(exe,
                 appname='WhateverYouWantToCallIt',
                 version=1)

at the bottom.

For my application, it made 70 files inside the .app file on default. –onefile makes it more neat and 3 times smaller in size! but it does make it a bit slower. If you care to make it as fast as possible, leave out that option but you have tofix a bug yourself.

Finally, build the application!

python Build.py YourApplication/YourApplication.spec

This will make your application and leave a YourApplication.app in your PyInstaller folder.

Fix the Application

Put your own nice icon on the application. Copy your graphic, right-click your application and choose Get Info, click the icon and paste the graphic.

Open the content of your application, open Contents/Info.plist, uncheck “Application is background only” and save. If you’re using a plain text editor, change LSBackgroundOnly to false.

There is only one last problem to deal with on mac. You have to copy the qt_menu.nib file.

locate qt_menu.nib

to find it. If you use MacPorts, it’s probably somewhere like /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib

Copy it to your YourApplication.app/Contents/Resources

Boom, you can double click your application and it will run!

Ok, one last problem, I swear. When you run, it shows 2 icons on the dock… pretty ugly. This hack can fix it, but it’s not perfect as it leaves junk on your computer. Hopefully PyInstaller can address it soon.

Conclusion

The program is beautiful! You don’t have to worry about your Python plug-ins, your 64-bitness, anything (mostly). It just works. I have yet to figure out how to make 32-bit binaries on 64-bit systems and how to make upx work properly to reduce executable size. I’m currently running at 32mb for an application that really should be 1mb. But then again, it’s packaging a whole new GUI framework that doesn’t exist on the target computer with the application. Consider Skype (yes, it’s infinitely more complex than my thing), it is still 43mb.

发表在 未分类 | 发表评论

install py2app on MacOSX

Installation

Uninstalling py2app 0.2.x (or earlier)

If you have a pre-setuptools version of py2app installed, you must first remove it before installing (you may have to run the interpreter with sudo, depending on how and where py2app was originally installed). There are three paths that need to be removed: py2app and py2app.pth in your site-packages folder, and thepy2applet script which may be in /usr/local/bin/ or otherwise in the bin directory belonging to the Python framework that was installed.

Here is a Python script that should find these three paths and remove them if they exist (you may have to use sudo):

#!/usr/bin/env python
import os, shutil
from distutils.sysconfig import *
py2app = os.path.join(get_python_lib(), 'py2app')
import shutil
if os.path.isdir(py2app):
    print "Removing " + py2app
    shutil.rmtree(py2app)

if os.path.exists(py2app + '.pth'):
    print "Removing " + py2app + '.pth'
    os.unlink(py2app + '.pth')

for path in os.environ['PATH'].split(':'):
    script = os.path.join(path, 'py2applet')
    if os.path.exists(script):
        print "Removing " + script
        os.unlink(script)

Installing with easy_install

To install py2app using easy_install you must make sure you have a recent version of setuptools installed (as of this writing, 0.6b4 or later):

$ curl -O http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py -U setuptools

To install or upgrade to the latest released version of py2app:

$ sudo easy_install -U py2app

Installing from source

To install py2app from source, simply use the normal procedure for installing any Python package. Since py2app uses setuptools, all dependencies (includingsetuptools itself) will be automatically acquired and installed for you as appropriate:

$ python setup.py install

If you’re using a svn checkout, it’s recommended to use the setuptools develop command, which will simply activate py2app directly from your source directory. This way you can do a svn up or make changes to the source code without re-installing every time:

$ python setup.py develop

Upgrade Notes

The setup.py template has changed slightly in py2app 0.3 in order to accommodate the enhancements brought on by setuptools. Old setup.py scripts look like this:

from distutils.core import setup
import py2app

setup(
    app=["myscript.py"],
)

New py2app scripts should look like this:

from setuptools import setup
setup(
    app=["myscript.py"],
    setup_requires=["py2app"],
)

发表在 未分类 | 发表评论