六月 20, 2011
» 在 Windows、Linux,以及 Mac 上安裝 pip - Python 套件管理程式

這篇是寫給沒用過 virtualenv 與 pip 的 Python 套件管理攻略。

PycTW 2011 上應該沒時間講這種事,還是先在這邊還攻略債吧。

步驟

先講一下原則上的建議安裝方式(同 pip 官方文件上的建議):利用 virtualenv 內建的 pip

  1. 下載 virtualenv.py
  2. python virtualenv.py [新專案環境目錄名]
  3. 進入 virtualenv 環境(在這個環境下安裝的東西不會影響到整個系統)
  4. 開始使用 pip 安裝套件

 

Linux 或 Mac 上的指令參考

$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py my_new_env
$ . my_new_env/bin/activate
(my_new_env)$ pip install ...

通常這樣就完成了 Linux 與 Mac 上的攻略。

 

Windows 上的指令參考

  1. 儲存那個網頁,命名檔案為 virtualenv.py
  2. 打開 terminal(cmd.exe 之類的),cd 到你要放專案資料夾的地方 (例: cd C:\Users\Keith )
  3. python virtualenv.py my_new_env
  4. my_new_env\Scripts\activate.bat
  5. pip install …

 2013-06-24 Update:

Windows 的 virtualenv 可能會遇到一些安裝 PIL 的問題,所以你可能會想要跳過 virtualenv 直接安裝 setuptools (小註:已於 0.7 版合併了 distribute)與 pip:

下載 https://raw.github.com/pypa/pip/master/contrib/get-pip.py

執行 pyhton get-pip.py

附錄

如何使用 pip 安裝一個名為 xxx(bottle, nose, Requests, SQLAlchemy, Pyramid, … 等等) 的套件?

pip install xxx

移除套件? pip uninstall xxx

» 在 Windows、Linux,以及 Mac 上安裝 pip - Python 套件管理程式

這篇是寫給沒用過 virtualenv 與 pip 的 Python 套件管理攻略。

PycTW 2011 上應該沒時間講這種事,還是先在這邊還攻略債吧。

步驟

先講一下原則上的建議安裝方式(同 pip 官方文件上的建議):利用 virtualenv 內建的 pip

  1. 下載 virtualenv.py
  2. python virtualenv.py [新專案環境目錄名]
  3. 進入 virtualenv 環境(在這個環境下安裝的東西不會影響到整個系統)
  4. 開始使用 pip 安裝套件

 

Linux 或 Mac 上的指令參考

$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py my_new_env
$ . my_new_env/bin/activate
(my_new_env)$ pip install ...

通常這樣就完成了 Linux 與 Mac 上的攻略。

 

Windows 上的指令參考

  1. 儲存那個網頁,命名檔案為 virtualenv.py
  2. 打開 terminal(cmd.exe 之類的),cd 到你要放專案資料夾的地方 (例: cd C:\Users\Keith )
  3. python virtualenv.py my_new_env
  4. my_new_env\Scripts\activate.bat
  5. pip install …

 2013-06-24 Update:

Windows 的 virtualenv 可能會遇到一些安裝 PIL 的問題,所以你可能會想要跳過 virtualenv 直接安裝 setuptools (小註:已於 0.7 版合併了 distribute)與 pip:

下載 https://raw.github.com/pypa/pip/master/contrib/get-pip.py

執行 pyhton get-pip.py

附錄

如何使用 pip 安裝一個名為 xxx(bottle, nose, Requests, SQLAlchemy, Pyramid, … 等等) 的套件?

pip install xxx

移除套件? pip uninstall xxx

十月 19, 2010
» To find the (updated) packages that requires reboot of Ubuntu

cat /var/run/reboot-required.pkgs

» To find the (updated) packages that requires reboot of Ubuntu

cat /var/run/reboot-required.pkgs

十月 17, 2010
» wget -r -l1 —no-parent -A.deb http://…/dir/

wget -r -l1 —no-parent -A.deb http://…/dir/

» wget -r -l1 —no-parent -A.deb http://…/dir/

wget -r -l1 —no-parent -A.deb http://…/dir/

十月 2, 2010
» 好吧,假如真的用了這個作業系統兩年半,到時就要出 Ubuntu 13.04 版……真的是,未來,一直一直來

九月 23, 2010
» 更新 435 個 Fedora 套件中,唯一看到有重開機的需求是 pykickstart

十二月 27, 2008
» Vim 7.2 on Ubuntu 8.10 & Arpeggio

It's a good time to have Vim 7.2 on Ubuntu 8.10 (Intrepid Ibex) now. To make it, we need to borrow something jaunty (and never give back).

  1. Vim, sure. But which? vim-gnome, vim-gtk, or vim-nox? It's not of my business to make this choice.
  2. Whatever, you will need vim-common, vim-runtime. If you want to go with GUI, don't forget your vim-gui-common.
  3. You may want to keep it easy, so keep your Intrepid Vim first. Install jaunty vim-common or vim-gui-common for GUI, then remove those old Vim packages. On my computer, they are:
    vim 1:7.1.314-3ubuntu3
    vim-common 1:7.1.314-3ubuntu3
    vim-gtk 1:7.1.314-3ubuntu3
    vim-gui-common 1:7.1.314-3ubuntu3
    vim-python 1:7.1.314-3ubuntu3
    vim-runtime 1:7.1.314-3ubuntu3
    vim-tiny 1:7.1.314-3ubuntu3
  4. And install new packages, for me:
    (After install vim-gui-common 2:7.2.025-2ubuntu1)
    vim-common 2:7.2.025-2ubuntu1
    vim-gtk 2:7.2.025-2ubuntu1
    vim-runtime
Hurray! We're done. Vim 7.2... but WHY? What for? How, When, Where?
Okay, okay, let's take something for fun.

But not much, I only come up with this: arpeggio, created by Kana Natsuno. This plugin can let you define another type of key-mapping, consists of 2 or more keys by simultaneously pressing them. The usage:

call arpeggio#map('i', '', 0, 'jk', '<esc>')
call arpeggio#map('i', '', 0, 'j<space>', '<esc>')

What is the difference with

inoremap jk <esc>
inoremap j<space> <esc>
?
Good question, or you already know that. In some bad daya you just want to key in 'jk' or 'j ' string but it <Esc><ESc><ESC>!!! God bless us, it doesn't have mercy at all. Nice trick, thanks Kana.

But I also found that it's not easy to press simultaneously on the kerboard, at least for me. So it does let you tweak a bit:

let g:arpeggio_timeoutlens = {'j':400, 'k':200, 'q':100}

You can have different definition of how long does it "simultaneously" in milliseconds. Then you don't need to get <esc> with 4 cups of coffee in order to press two keys.

Have fun!

十一月 8, 2008
» QT4 軟體:生活中的重量級武器

我(還)沒用 KDE4 做為主要桌面管理系統,但它的一些重量級武器卻強而有力地值得擁有。特此一記:

  • gwenview:用過就不會想要其它(同類重量級)的圖片瀏覽程式……除非要直接上傳到網路上。

  • okular:當 Evince 看中文有問題,以為又得開 acroread 時,出人意料地 Okular 可以,也吃 cht 檔,詳見它的 format handler,故此推。

  • k9copy:它吃了 DVD Shrink 吃不了的片。

另外,SMPlayer 也是個傑作,相當棒的 mplayer 的 front-end player;更棒的是,它只需 QT4 的 lib,不需連帶 KDE4 的整堆 lib。

十月 7, 2008
» 當我們~同在一起 R M 減 R M **/* 【救回資料篇】

今天是資源回收日。來撿回我們的 rm -rf 檔吧。
Google了一下,Ubuntu 上大概有兩三套可以玩。因為我只是在 projects/ 下 rm -rf * 而已。所以不痛不癢。(目向遠方,滴淚打轉)
所以flat (text)檔才是我的重點,而非什麼 rm、jpg、或 mp3 檔;否則有其它的工具可對那些多媒體檔做復元。

ext2、fat,甚至連 ntfs 都有看來頗方便的工具,那 ext3 呢?有!ext3grep

因為 Ubuntu 還沒時間把它收進 package,所以要裝還是得靠它(tar)。解開後 ./configure && make && make install 。我的情況是要另外 apt install ext2lib-dev 與 g++ 才能過 ./configure 。

ext3grep 的用法不少,參見。以下簡述我的過程:

apt install gddrescue。as root:
# umount /home
# mount /dev/sdb3 /mnt/sdb3 ## 救援用大容量硬碟,因為我的sda容量渺茫…
# ddrecsue -r /dev/sda6 /mnt/sdb3/sda6image ## sdaN 視原來 /home mount 在哪個 /dev 下而定
# cd /mnt/sdb3/
# mkdir ext3grep
# cd ext3grep
# ext3grep /mnt/sdb3/sda6image --dump-names

此時我看了一下它生出來的 sda6image.ext3grep.stage2,我想回復的資料夾是
keitheis/Conquer,故:
# grep "keitheis/Conquer'" sda6image.ext3grep.stage2 ## 剛剛 dump-names 生出來的東西
50835 'keitheis/Conquer' 129126

當然,/mnt/sdb3 應該要比 /dev/sda6 的容量會比較安心。接著的指令會把在 129126 inode 後的 inode 檔通通恢復,不只是 Conquer 下,是指整個 /home。so in /mnt/sdb3/ext3grep
# ext3grep ../sda6image --restore-all --after=129126

/home 的資料就會開始行屍走肉到 RESTORED_FILES/ 下。接著就是檢視並選擇性 copy 回去的工作了。我的 Conquer 資料夾很早就建立了,所以它也幾乎把 90% 的 /home 抓出來。

註:試用 foremost 工具產生了一堆 inode 名的檔案,要再重新一一命名?不太人性。不過就相機的圖片而言也許沒差。

六月 17, 2008
» gcin v.s. Firefox3

話說原來 Firefox 3 無法自行重開的關係,是因為 ubuntu 官方套件的 gcin。於是我昨晚動手試了安裝 debian 的 gcin bpo 版,或自行編譯 gcin 1.4.0,再以 checkinstall 安裝,但結果都是得把 roxterm 中的 input methods 切到 xim 才能輸入,也就是 Firefox 就用不了 gcin。最後在睡眠的誘惑下,我乖乖裝回 hardy 的 gcin。參照幾個連結:

不過重點來了,在 Firefox 的輸入欄按下箭頭不會卡在那裡了!那也是另一個很惱人的問題。yeah

六月 16, 2008
» (the).deb is missing final newline

剛剛忽然發生了一個 (the).deb missing 事件,googled 有些人也發生和我一樣的狀況,而我用的是那一串最尾端的解法:

cd /var/lib/dpkg/info
sudo mkdir hidden
sudo mv (the).deb hidden
sudo apt-get --reinstall install (the).deb

(the).deb 指的是出現問題的那個deb,或那些debs,請自行置換。

四月 29, 2008
» Synergy Hurrah!

I have two computers plus one EeePC. Now I try to have them ALL under my control in single keyboard and mouse. Since I had the Ubuntu Hardy Heron installed, they told me there are something easy to go with VNC. Okay, I tried. Both easy-go VNC clients(vinagre and krdc) can't satisfy me. Vinagre is just a viewer, so I can't control another machine. It's not its fault, but what I got on the screen is hard from great. I don't know if that is because my old machine's performance problem. Then, Krdc as a KDE VNC client cooperates with krfb has a nice mechanism for invitation in occasional usage. But what I want is long-term relationship!? Anyway, it has same output with vinagre. Finally I found one interesting package named x2vnc in my apt list. I googled it, got some discuss threads, so as the title you can guess, I choose Synergy as my favor.

Followed links above, I got my cursor go to server PC from my laptop! That's great! What I still need is to configure it to automatically start. Let me digg more.

» Upgrade & Install The *buntu 8.04

My weekend was taken by Ubuntu 8.04. On my damnhell ASUS A2H Notebook, there is a Combo DVD-Rom which even can't read parts of cd-rom more than 50 MB (no mention of DVD), though that depends, but that's it in almost 95% lucky situation. In the end I agree with its fate to use 9 MB Minimal CD. I finished the installation of 7.10 basic-command system, and finally could do the `sudo do-release-upgrade` to the Hardy Heron.

Okay, that screenshot maybe not that attractive. But it worth a try. ;)


I've tried KDE4 on EeePC 701, so I guess to use it on my work machine should be nice. And yes, it's really fun to use and ... little trouble to deal. One thing is switching from Pidgin to Kopete. I've used Kopete years ago and at that time it's good enough. But now, as I'm more hard to take, and as it's KDE4, Kopete become not good enough for me. It's still lack the IRC protocol surport in KDE 4.0.3.. But that's okay, just to make Kopete work with gtalk in *buntu, you need to install "qca-tls" like it said. KDE Wiki: Google Talk support

As you can see, I very like Emotion background. Attached the expose as the end. But! It's not the end. After the happy time they have gone, and brought this out for some thing wrong:

Anyway, let's call it a life. Good day.

You may also be interested:

四月 25, 2008
» What I installed? What can I install? Grep APT Packages

mkdir ~/tmp

Put this in your .zshrc or .bashrc
alias dl='dpkg -l > ~/tmp/dl'
alias dlg="cat ~/tmp/dl | sed -e 's/ii \([a-zA-Z\-]*[[:space:]]*[0-9a-zA-Z\.:\-]*\).*/\1/' | grep -i"
alias al='apt-cache pkgnames > ~/tmp/al'
alias alg='cat ~/tmp/al | grep'

Ok, that's done. Let us try:
% dl
will cache a list of packages you have installed.
% dl python
will list all packages' name contains 'python' string.
% al
will cache a list of available packages.
% alg 'kde4'
will list all packages' name contains 'kde4' string.
I use these a lot. Hope this will help.

biggo.com.tw

A Django site.