pinax建项目

这篇博客介绍了如何使用Pinax创建Python项目,包括安装Pinax时可能遇到的错误及解决方案,创建项目的基本步骤,以及运行项目的命令。在安装过程中,可能会遇到版本不兼容的问题,需要指定版本进行安装。在创建项目时,可以使用不同类型的项目基来作为起点,通过`pinax-admin`命令进行操作。最后,通过`syncdb`和`runserver`命令启动项目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、 Prerequisites
To get started with Pinax you must have the following installed:
• Python 2.4+ — many OSes come with an adequate version of Python. If you are on Windows you will need to
install it from python.org. Do not install Python 3+. Pinax is not compatible with Python 3 yet.
• virtualenv 1.4.7+
• pysqlite — this is only required if you are running Python 2.4. Later versions of Python have this bundled.

• PIL — this is only required if you are using a project which requires imaging capabilites (includes projects which support avatars and/or photos). It is likely the best idea to install it anyways.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

二、 Installation


Pinax highly encourges the use of virtual environments. We will use a tool called virtualenv which provides a way to create isolated Python environments.
Create yourself a virtual environment and activate it:
$ virtualenv mysite-env
$ source mysite-env/bin/activate
(mysite-env)$

If you use Windows this will become:
$ virtualenv mysite-env
$ mysite-env\Scripts\activate.bat

(mysite-env)$


The directory mysite-env is the environment for your project. It is recommended you do not edit or create new files/directories within it. The reason this is important is that this directory should remain reproducible at all times.Reproducible environments is a good idea.Notice the (mysite-env) bit? This is done for you by the activate script to help you identify which en-vironment is currently activated. Under the hood your PATH has been modified to use the Python binary for thisenvironment.

Go ahead and install Pinax:


(mysite-env)$ pip install Pinax


不过有可能会出现以下错误:

Could not find a version that satisfies the requirement pinax (from versions: 0.9a2)

因为pip使用新的 pip call 法(pip.util.call_subprocess), 故你只能使用新版的方法安装,

所以这里只要换成指定版本的方法安裝即可:$pip install  产品名称==版本pip install pinax==0.9a2

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

三、Creating a project

Now that Pinax is installed the next step is to create a project. A project is not much more than a Django project. Pinax
provides many more defaults for you out of the box.

(mysite-env)$ pinax-admin setup_project mysite

This will create a new project named mysite. By default it will install dependencies for you. You can turn that behavior off by giving setup_project the --no-reqs option.
Pinax comes with many different project bases. The default project based is what we call layer zero. It is simply a Django project with some extra integrated dependencies that will make getting started faster.Specifying a different project base
To see what Pinax has to offer run:

(mysite-env)$ pinax-admin setup_project -l

This will list all available project bases and a short description about each. To base your project off of any of these


you’d run:

(mysite-env)$ pinax-admin setup_project -b basic mysite

In many cases the default (zero) is enough to get you going, but others may provide a better starting point for your
project.



创建工程时有可能会出现AttributeError: 'module' object has no attribute 'call_subprocess'错误

出现该问题是因为使用了新版本的pip,而在新版本的pip中,原pip.call_subprocess已经移到了pip.util.call_subprocess

因而引发异常。解决方法很简单,进入pinax目录下的core\management\commands子目录,修改setup_project.py

将其中的pip.call_subprocess改为pip.util.call_subprocess即可。

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

四、 Running a project
At this point you are now working with Django. Pinax has helped you bootstrap your project into life. Inside your
project you should run:
(mysite-env)$ python manage.py syncdb
(mysite-env)$ python manage.py runserver

 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值