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

Python 学习记录

2013-10-10 18:47 387 查看
记录一些 学习python 的过程

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

1. 初始学习

@2013年10月6日

今天开始学习python 了

遇到好多困难但是都一个个解决了

安装pyhton

http://www.python.org/

安装setuptools
https://pypi.python.org/pypi/setuptools/1.1.6
安装pip

https://pypi.python.org/pypi/pip

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

最开始选择的最新的3.3.X 结合 django 1.5 发现很多问题 又换到2.7.X 先安装 mysqldb 然后安装django

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

2. Unable to find vcvarsall.bat

@2013年10月8日 23:42:55

在使用django 的 ImageFields 碰到问题:

问题 To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/
下载 pil 是python处理图形的组件, 进入http://www.pythonware.com/products/pil/ 选择合适的版本下载安装 写着文章的时候最新版本是 PIL 1.1.7 (November 15, 2009 ) 提供的都是32为系统的 推荐下载源码包安装。

解压下载的文件 在setup.py 所在目录下使用 python setup.py install 安装 (注意读下文件的 readme 可以得到很多消息)

如果 发现 报错 Unable to find vcvarsall.bat 参见blog 解决

然后运行:

setup.py install build --compiler=mingw32


可惜我这几种方案都没有解决啊~~ 只有安装vs了,瞬间有了放弃win8投身到linux 怀抱中去了的冲动。

参考 :http://www.crifan.com/python_mmseg_error_unable_to_find_vcvarsall_bat/

http://www.crifan.com/while_install_scrapy_error_unable_to_find_vcvarsall_bat/

http://www.linuxidc.com/Linux/2011-08/39722.htm

下载了 vs2012试用版 然后

查看环境变量 :VS110COMNTOOLS --> E:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\

vcvarsall32.bat 就在这个目录下

添加环境变量: VS90COMNTOOLS ---> %VS110COMNTOOLS%

运行 setup.py install 成功编译成功了。

2013年10月10日 18:44:50 到现在这个问题解决了~~~ 哈哈

通读源码会有更多收获啊~~~ 现在还看得不是很懂啊~~~ 加油学习 go~~~go~~~

3. 关于django 的文件上传以及静态资源配置

@2013年10月11日 00:32:33

在 setting.py 文件里面设置

MEDIA_ROOT , MEDIA_URL , STATIC_ROOT , STATIC_URL
这些变量是什么意思呢可以参考

http://hgoldfish.com/blogs/article/77/

https://docs.djangoproject.com/en/dev/howto/static-files/

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

客户上传的图片url添加这些配置

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


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

服务器静态资源文件 url 配置 比如 css js 用到的图片这些

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
# ... the rest of your URLconf goes here ...
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)


当遇到不明白的地方多谷歌多看官方doc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: