install lib ที่เราสร้างขึ้น

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

คือผมสร้าง class ที่ต้องการใช้งานไว้แล้ว
แต่ผมอยากให้มันถูกเรียกใช้งานโดยการ import เข้ามานะครับ
แต่ผม set ค่าให้มันเรียกไม่ถูกนะครับ
ไม่เข้าใจว่าต้องนำ class ที่เราสร้างไปใส่ไว้ใน lib ของ python เอง
หรือว่าใส่ไว้ใน folder ของเราเอง แต่ลองแล้วทั้ง 2 แบบ ก็ไม่ได้นะครับ

OS: windows
python: 2.5

sugree's picture

ไว้ตรงไหนก็ได้ที่อยู่ใน PYTHONPATH ลองดูใน sys.path ว่ามีที่ไหนบ้าง

ทำแบบง่ายๆ ก็ใช้ setuptools หรือ distutils ก็ได้

fyi's picture

If you want to tell python that your directory is python module, put __init__.py (with empty content) in your directory.
If you know exactly what is a path, you can dinamically append path, like so;

import sys
sys.path.append('your path')

;)

khao_lek's picture

kobkhun krub.

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น