Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-02 23:36:44 10月01日 Update

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.

Tags: Directories notes configuration steps parameters practice applications methods more versions knowledge articles tests utility code commands done that is work sessions articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Apple Microsoft Redmi