Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the nine steps for the practical application of Python installation notes?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article to share with you is about Python installation notes of the actual application of the nine steps are what, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.

The following steps are some of the documentation of your own configuration process. Also note the indentation of the test code.

1. Download a new version (note version issues apache and python versions)

2. Copy it to the linux machine, and execute Python installation notes on the command line below:

tar -zxvf mod_python-3.3.1.tgz cd mod_python-3.3.1 ./ configure --with-apxs=/usr/local/apache/bin/apxs

Configure apxs directory

./ configure --with-python=/usr/bin/python2.5

Configure local python

make make install

3. When these are compiled, mod_python.so will be generated in apache/modules/directory, about 3M.

4. http.conf for apache

LoadModule python_module modules/mod_python.so

directories accessible with apache

#AddHandler mod_python .py SetHandler mod_python PythonHandler mod_python.publisher PythonDebug On

5. Test Create a new test.py in/usr/modpython/

#coding:gb2312 def index(req): req.write("hello,world! ") return

6. Run Python installation notes, start apache without errors after

7. Define other methods:

#coding:gb2312 def index(req): req.write("hello,world! ") return def hello(req): req.write("hello!!! ") return

8. pass parameters

def get(req,name=""): if name: req.write("argument: "+name); else: req.write("no param. "); return

POST forms are the same, as long as the parameter names are written correctly.

9.Python package creates a package in the current directory, and then an error occurs when importing test.py, and the package cannot be found. Then I changed the method.

import os,sys sys.path.append(os.path.dirname(__file__))

Add the current directory to sys.path import own package

The above is what the nine steps of the actual application of Python installation notes are, Xiaobian believes that some of the knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report