我已經安裝了django和python作爲this link與macports建議。但是,我想使用virtualenv來安裝更多的軟件包。我的理解是,如果我不要通過--no-site-packages
到virtualenv
,除了我安裝到虛擬環境中的任何軟件包之外,我應該得到當前安裝的軟件包。它是否正確?Macports和virtualenv網站包fallback
舉個例子,我已經通過的MacPorts安裝的Django,然後創建一個虛擬的環境,但我不能從虛擬環境中導入Django的:
[[email protected]]:~$ mkvirtualenv django-test
New python executable in django-test/bin/python
Installing setuptools............done.
...
(django-test)[[email protected]]:~$ pip install django-debug-toolbar
Downloading/unpacking django-debug-toolbar
Downloading django-debug-toolbar-0.8.4.tar.gz (80Kb): 80Kb downloaded
Running setup.py egg_info for package django-debug-toolbar
Installing collected packages: django-debug-toolbar
Running setup.py install for django-debug-toolbar
Successfully installed django-debug-toolbar
Cleaning up...
(django-test)[[email protected]]:~$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
這樣我就可以安裝包到虛擬環境,但它並沒有拿起全球網站包。或者我沒有正確地做某件事/錯過某些東西/誤解virtualenv
如何工作?
我有Mac OS 10.6(Snow Leopard),已更新我的macports軟件包,並使用macports的python26(通過python_select python26
)。
編輯:
而且我檢查了我的MacPorts的PATH是否設置正確。下面是一些輸出:
[[email protected]]:~$ python --version
Python 2.6.6
[[email protected]]:~$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/streeter/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/streeter/.ec2/bin
[[email protected]]:~$ source dev/python-environments/test/bin/activate
(test)[[email protected]]:~$ python --version
Python 2.6.1
(test)[[email protected]]:~$
virtualenv
和virtualenvwrapper
均被安裝在使用pip
,不使用MacPorts的作爲似乎沒有在/usr/local/bin/virtualenvwrapper.sh
創建一個文件源,所以我不知道怎麼去的別名virtualenvwrapper。
你試過了嗎? – jfs 2011-01-12 17:51:07