Настройка пути Python для версии trunk Django

Эскизы были сделаны с libswfdec (т. е. /usr/bin/swfdec-thumbnailer из пакета swfdec-gnome), который был удален в Ubuntu 10.10 («maverick»). Автор libswfdec прекратил разработку, потому что уже есть 2 других проекта с открытым исходным кодом, работающих над внедрением SWF-плеера: gnash (который включен в Ubuntu) & amp; lightspark (который является новым и еще не включен). Я не уверен, существует ли thumbnailer, который использует gnash ...

7
задан 27 February 2011 в 01:28

18 ответов

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

. Это добавит пути к существующему списку путей python .

python.org:

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, путь поиска начинается с
['/www/python','/opt/py']
(обратите внимание, что каталоги должны существовать для того, чтобы быть добавлен в sys.path, модуль сайта удаляет пути, которые не существуют.)

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ваш

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример Django-centric из djangotricks (blog):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также может редактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: djangotricks python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: файлы настроек Django для разработки и производства

6
ответ дан 25 May 2018 в 22:48

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

. Это добавит пути к существующему списку путей python .

python.org:

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, путь поиска начинается с ['/www/python','/opt/py'] (обратите внимание, что каталоги должны существовать для того, чтобы быть добавлен в sys.path, модуль сайта удаляет пути, которые не существуют.)

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ваш

Пример из python.org :

$ python Python 2.2 (#11, Oct 3 2002, 13:31:27) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages'] >>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример Django-centric из djangotricks (blog):

import os, sys SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk") PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk") sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также может редактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py """Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** In earlier versions of Python (up to 1.5a3), scripts or modules that needed to use site-specific modules would place ``import site'' somewhere near the top of their code. Because of the automatic import, this is no longer necessary (but code that does it still works). This will append site-specific paths to the module search path. On Unix (including Mac OSX), it starts with sys.prefix and sys.exec_prefix (if different) and appends lib/python<version>/site-packages as well as lib/site-python. On other platforms (such as Windows), it tries each of the prefixes directly, as well as with lib/site-packages appended. The resulting directories, if they exist, are appended to sys.path, and also inspected for path configuration files. For Debian and derivatives, this sys.path is augmented with directories for packages distributed within the distribution. Local addons go into /usr/local/lib/python<version>/dist-packages, Debian addons install into /usr/{lib,share}/python<version>/dist-packages. /usr/lib/python<version>/site-packages is not used. A path configuration file is a file whose name has the form <package>.pth; its contents are additional directories (one per line) to be added to sys.path. Non-existing directories (or non-directories) are never added to sys.path; no directory is added to sys.path more than once. Blank lines and lines beginning with '#' are skipped. Lines starting with 'import' are executed. For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local and there is a directory /usr/local/lib/python2.5/site-packages with three subdirectories, foo, bar and spam, and two path configuration files, foo.pth and bar.pth. Assume foo.pth contains the following: # foo package configuration foo bar bletch and bar.pth contains: # bar package configuration bar Then the following directories are added to sys.path, in this order: /usr/local/lib/python2.5/site-packages/bar /usr/local/lib/python2.5/site-packages/foo Note that bletch is omitted because it doesn't exist; bar precedes foo because bar.pth comes alphabetically before foo.pth; and spam is omitted because it is not mentioned in either path configuration file. After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored.

Ссылки: djangotricks python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: файлы настроек Django для разработки и производства

6
ответ дан 25 July 2018 в 22:26

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

. Это добавит пути к существующему списку путей python .

python.org:

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, путь поиска начинается с ['/www/python','/opt/py'] (обратите внимание, что каталоги должны существовать для того, чтобы быть добавлен в sys.path, модуль сайта удаляет пути, которые не существуют.)

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ваш

Пример из python.org :

$ python Python 2.2 (#11, Oct 3 2002, 13:31:27) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages'] >>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример Django-centric из djangotricks (blog):

import os, sys SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk") PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk") sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также может редактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py """Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** In earlier versions of Python (up to 1.5a3), scripts or modules that needed to use site-specific modules would place ``import site'' somewhere near the top of their code. Because of the automatic import, this is no longer necessary (but code that does it still works). This will append site-specific paths to the module search path. On Unix (including Mac OSX), it starts with sys.prefix and sys.exec_prefix (if different) and appends lib/python<version>/site-packages as well as lib/site-python. On other platforms (such as Windows), it tries each of the prefixes directly, as well as with lib/site-packages appended. The resulting directories, if they exist, are appended to sys.path, and also inspected for path configuration files. For Debian and derivatives, this sys.path is augmented with directories for packages distributed within the distribution. Local addons go into /usr/local/lib/python<version>/dist-packages, Debian addons install into /usr/{lib,share}/python<version>/dist-packages. /usr/lib/python<version>/site-packages is not used. A path configuration file is a file whose name has the form <package>.pth; its contents are additional directories (one per line) to be added to sys.path. Non-existing directories (or non-directories) are never added to sys.path; no directory is added to sys.path more than once. Blank lines and lines beginning with '#' are skipped. Lines starting with 'import' are executed. For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local and there is a directory /usr/local/lib/python2.5/site-packages with three subdirectories, foo, bar and spam, and two path configuration files, foo.pth and bar.pth. Assume foo.pth contains the following: # foo package configuration foo bar bletch and bar.pth contains: # bar package configuration bar Then the following directories are added to sys.path, in this order: /usr/local/lib/python2.5/site-packages/bar /usr/local/lib/python2.5/site-packages/foo Note that bletch is omitted because it doesn't exist; bar precedes foo because bar.pth comes alphabetically before foo.pth; and spam is omitted because it is not mentioned in either path configuration file. After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored.

Ссылки: djangotricks python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: файлы настроек Django для разработки и производства

6
ответ дан 31 July 2018 в 11:13

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

. Это добавит пути к существующему списку путей python .

python.org:

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, путь поиска начинается с ['/www/python','/opt/py'] (обратите внимание, что каталоги должны существовать для того, чтобы быть добавлен в sys.path, модуль сайта удаляет пути, которые не существуют.)

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ваш

Пример из python.org :

$ python Python 2.2 (#11, Oct 3 2002, 13:31:27) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages'] >>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример Django-centric из djangotricks (blog):

import os, sys SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk") PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk") sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также может редактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py """Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** In earlier versions of Python (up to 1.5a3), scripts or modules that needed to use site-specific modules would place ``import site'' somewhere near the top of their code. Because of the automatic import, this is no longer necessary (but code that does it still works). This will append site-specific paths to the module search path. On Unix (including Mac OSX), it starts with sys.prefix and sys.exec_prefix (if different) and appends lib/python<version>/site-packages as well as lib/site-python. On other platforms (such as Windows), it tries each of the prefixes directly, as well as with lib/site-packages appended. The resulting directories, if they exist, are appended to sys.path, and also inspected for path configuration files. For Debian and derivatives, this sys.path is augmented with directories for packages distributed within the distribution. Local addons go into /usr/local/lib/python<version>/dist-packages, Debian addons install into /usr/{lib,share}/python<version>/dist-packages. /usr/lib/python<version>/site-packages is not used. A path configuration file is a file whose name has the form <package>.pth; its contents are additional directories (one per line) to be added to sys.path. Non-existing directories (or non-directories) are never added to sys.path; no directory is added to sys.path more than once. Blank lines and lines beginning with '#' are skipped. Lines starting with 'import' are executed. For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local and there is a directory /usr/local/lib/python2.5/site-packages with three subdirectories, foo, bar and spam, and two path configuration files, foo.pth and bar.pth. Assume foo.pth contains the following: # foo package configuration foo bar bletch and bar.pth contains: # bar package configuration bar Then the following directories are added to sys.path, in this order: /usr/local/lib/python2.5/site-packages/bar /usr/local/lib/python2.5/site-packages/foo Note that bletch is omitted because it doesn't exist; bar precedes foo because bar.pth comes alphabetically before foo.pth; and spam is omitted because it is not mentioned in either path configuration file. After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored.

Ссылки: djangotricks python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: файлы настроек Django для разработки и производства

6
ответ дан 2 August 2018 в 03:52

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

Это будет добавить пути [gg] python.org :

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, поиск путь будет начинаться с

['/www/python','/opt/py']

(обратите внимание, что каталоги должны существовать для добавления в sys.path, модуль сайта удаляет пути, которые не существуют).

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ветку тестирования.

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример из Django-центрирования из djangotricks (блог):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также можете отредактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: python. org docs, v2.7 search path python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: настройки Django файлы для разработки и производства

6
ответ дан 4 August 2018 в 19:56

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

Это будет добавить пути [gg] python.org :

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, поиск путь будет начинаться с

['/www/python','/opt/py']

(обратите внимание, что каталоги должны существовать для добавления в sys.path, модуль сайта удаляет пути, которые не существуют).

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ветку тестирования.

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример из Django-центрирования из djangotricks (блог):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также можете отредактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: python. org docs, v2.7 search path python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: настройки Django файлы для разработки и производства

6
ответ дан 6 August 2018 в 03:58

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

Это будет добавить пути [gg] python.org :

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, поиск путь будет начинаться с

['/www/python','/opt/py']

(обратите внимание, что каталоги должны существовать для добавления в sys.path, модуль сайта удаляет пути, которые не существуют).

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ветку тестирования.

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример из Django-центрирования из djangotricks (блог):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также можете отредактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: python. org docs, v2.7 search path python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: настройки Django файлы для разработки и производства

6
ответ дан 7 August 2018 в 21:56

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

Это будет добавить пути [gg] python.org :

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, поиск путь будет начинаться с

['/www/python','/opt/py']

(обратите внимание, что каталоги должны существовать для добавления в sys.path, модуль сайта удаляет пути, которые не существуют).

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ветку тестирования.

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример из Django-центрирования из djangotricks (блог):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также можете отредактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: python. org docs, v2.7 search path python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: настройки Django файлы для разработки и производства

6
ответ дан 10 August 2018 в 10:11

Из bash (или другой оболочки) вы можете манипулировать $ PYTHONPATH, чтобы указать на родительский каталог, например echo $PYTHONPATH export PYTHONPATH="/newhome/django_x.x/trunk"

Это будет добавить пути [gg] python.org :

Например, если для параметра PYTHONPATH установлено значение /www/python:/opt/py, поиск путь будет начинаться с

['/www/python','/opt/py']

(обратите внимание, что каталоги должны существовать для добавления в sys.path, модуль сайта удаляет пути, которые не существуют).

Изнутри python вы также можете изменить sys.path (import sys, если вы этого не сделали), чтобы указать на ветку тестирования.

Пример из python.org :

$ python
Python 2.2 (#11, Oct  3 2002, 13:31:27)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
 '/usr/local/lib/python2.3/site-packages']
>>>

Чтобы добавить путь, используйте что-то вроде:

sys.path.append('/workingdir/python/')

Пример из Django-центрирования из djangotricks (блог):

import os, sys

SVN_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
DJANGO_PATH = os.path.join(SVN_PATH, "django_src", "trunk")
PROJECT_PATH = os.path.join(SVN_PATH, "myproject", "trunk")

sys.path += [DJANGO_PATH, PROJECT_PATH]

Кроме того, если вы не подавили поведение, python загружает site.py при выполнении, поэтому вы также можете отредактировать файл site.py, например /usr/lib/python2.7/site.py:

Замечания файла site.py также поучительны.

$ more /usr/lib/python2.7/site.py
"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages,
Debian addons
install into /usr/{lib,share}/python<version>/dist-packages.
/usr/lib/python<version>/site-packages
is not used.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory
/usr/local/lib/python2.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.5/site-packages/bar
  /usr/local/lib/python2.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes
foo
because bar.pth comes alphabetically before foo.pth; and
spam is
omitted because it is not mentioned in either path configuration
file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Ссылки: python. org docs, v2.7 search path python.org docs, v3 путь поиска Блог Djangotricks, примечание о путях python Мартин Янсен: настройки Django файлы для разработки и производства

6
ответ дан 13 August 2018 в 16:32

Хороший вопрос. Вы можете решить эту проблему с помощью python. Откройте интерпретатор python и

Python 2.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages', '/usr/lib/site-python']

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python, например

>>> sys.path.append('/path/to/django/trunk')
>>> sys.path.insert(0, '/path/to/django/trunk')

Либо один из эта команда должна добавить его к вашему пути.

1
ответ дан 25 May 2018 в 22:48
  • 1
    Ну, по крайней мере, наши ответы не являются полностью избыточными. ;) – belacqua 26 February 2011 в 22:55
  • 2
    за то, что он хочет сделать; это правильный способ сделать это. поэтому по крайней мере некоторые из наших ответов не совсем ошибочны. :П – myusuf3 27 February 2011 в 00:14
  • 3
    @dustyprogrammer Хм, я считаю, что часть моей информации была неправильной, по крайней мере, согласно python.org. Я заменил эту информацию и расширил ее. Я не пользователь django, поэтому я добавил пару ссылок на django-centric. – belacqua 27 February 2011 в 01:22
  • 4
    @jgbelacqua haha ​​копирует и вставляет вещи из Google, вы получите необходимую информацию даже без понимания. Теперь кто копирует кого? :) – myusuf3 27 February 2011 в 10:19
  • 5
    @dusty Я «копирую». python.org и другие ссылки, которые я цитировал, но пытаюсь использовать их в терминах, которые полезны для ОП и понятны мне. Я не уверен, почему вы считаете нужным оскорблять. – belacqua 27 February 2011 в 10:55

Хороший вопрос. Вы можете решить эту проблему с помощью python. Откройте интерпретатор python и

Python 2.6 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/site-python']

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python, например

>>> sys.path.append('/path/to/django/trunk') >>> sys.path.insert(0, '/path/to/django/trunk')

Либо один из эта команда должна добавить его к вашему пути.

1
ответ дан 25 July 2018 в 22:26
  • 1
    Ну, по крайней мере, наши ответы не являются полностью избыточными. ;) – belacqua 26 February 2011 в 22:55
  • 2
    за то, что он хочет сделать; это правильный способ сделать это. поэтому по крайней мере некоторые из наших ответов не совсем ошибочны. :П – myusuf3 27 February 2011 в 00:14
  • 3
    @dustyprogrammer Хм, я считаю, что часть моей информации была неправильной, по крайней мере, согласно python.org. Я заменил эту информацию и расширил ее. Я не пользователь django, поэтому я добавил пару ссылок на django-centric. – belacqua 27 February 2011 в 01:22
  • 4
    @jgbelacqua haha ​​копирует и вставляет вещи из Google, вы получите необходимую информацию даже без понимания. Теперь кто копирует кого? :) – myusuf3 27 February 2011 в 10:19
  • 5
    @dusty Я «копирую». python.org и другие ссылки, которые я цитировал, но пытаюсь использовать их в терминах, которые полезны для ОП и понятны мне. Я не уверен, почему вы считаете нужным оскорблять. – belacqua 27 February 2011 в 10:55

Хороший вопрос. Вы можете решить эту проблему с помощью python. Откройте интерпретатор python и

Python 2.6 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/site-python']

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python, например

>>> sys.path.append('/path/to/django/trunk') >>> sys.path.insert(0, '/path/to/django/trunk')

Либо один из эта команда должна добавить его к вашему пути.

1
ответ дан 31 July 2018 в 11:13
  • 1
    Ну, по крайней мере, наши ответы не являются полностью избыточными. ;) – belacqua 26 February 2011 в 22:55
  • 2
    за то, что он хочет сделать; это правильный способ сделать это. поэтому по крайней мере некоторые из наших ответов не совсем ошибочны. :П – myusuf3 27 February 2011 в 00:14
  • 3
    @dustyprogrammer Хм, я считаю, что часть моей информации была неправильной, по крайней мере, согласно python.org. Я заменил эту информацию и расширил ее. Я не пользователь django, поэтому я добавил пару ссылок на django-centric. – belacqua 27 February 2011 в 01:22
  • 4
    @jgbelacqua haha ​​копирует и вставляет вещи из Google, вы получите необходимую информацию даже без понимания. Теперь кто копирует кого? :) – myusuf3 27 February 2011 в 10:19
  • 5
    @dusty Я «копирую». python.org и другие ссылки, которые я цитировал, но пытаюсь использовать их в терминах, которые полезны для ОП и понятны мне. Я не уверен, почему вы считаете нужным оскорблять. – belacqua 27 February 2011 в 10:55

Хороший вопрос. Вы можете решить эту проблему с помощью python. Откройте интерпретатор python и

Python 2.6 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/site-python']

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python, например

>>> sys.path.append('/path/to/django/trunk') >>> sys.path.insert(0, '/path/to/django/trunk')

Либо один из эта команда должна добавить его к вашему пути.

1
ответ дан 2 August 2018 в 03:52
  • 1
    Ну, по крайней мере, наши ответы не являются полностью избыточными. ;) – belacqua 26 February 2011 в 22:55
  • 2
    за то, что он хочет сделать; это правильный способ сделать это. поэтому по крайней мере некоторые из наших ответов не совсем ошибочны. :П – myusuf3 27 February 2011 в 00:14
  • 3
    @dustyprogrammer Хм, я считаю, что часть моей информации была неправильной, по крайней мере, согласно python.org. Я заменил эту информацию и расширил ее. Я не пользователь django, поэтому я добавил пару ссылок на django-centric. – belacqua 27 February 2011 в 01:22
  • 4
    @jgbelacqua haha ​​копирует и вставляет вещи из Google, вы получите необходимую информацию даже без понимания. Теперь кто копирует кого? :) – myusuf3 27 February 2011 в 10:19
  • 5
    @dusty Я «копирую». python.org и другие ссылки, которые я цитировал, но пытаюсь использовать их в терминах, которые полезны для ОП и понятны мне. Я не уверен, почему вы считаете нужным оскорблять. – belacqua 27 February 2011 в 10:55

Хороший вопрос. Вы можете решить эту проблему с помощью python. Открытый интерпретатор python и

  Python 2.6 Введите «помощь», «авторское право», «кредиты» или «лицензия» для получения дополнительной информации.  & GT; & GT; & GT;  import sys & gt; & gt; & gt; & gt; & gt; & gt;  print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/ usr / lib  /python2.4/lib-tk ',' /usr/lib/python2.4/lib-dynload ',' /usr/local/lib/python2.4/site-packages ',' / usr / lib / python2.   

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python , например

  & gt; & gt; & gt; & gt;  sys.path.append ('/ path / to / django / trunk') & gt; & gt; & gt; & gt; & gt;  sys.path.insert (0, '/ path / to / django / trunk')  

Любая из этих команд должна добавить его к вашему пути.

1
ответ дан 4 August 2018 в 19:56

Хороший вопрос. Вы можете решить эту проблему с помощью python. Открытый интерпретатор python и

  Python 2.6 Введите «помощь», «авторское право», «кредиты» или «лицензия» для получения дополнительной информации.  & GT; & GT; & GT;  import sys & gt; & gt; & gt; & gt; & gt; & gt;  print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/ usr / lib  /python2.4/lib-tk ',' /usr/lib/python2.4/lib-dynload ',' /usr/local/lib/python2.4/site-packages ',' / usr / lib / python2.   

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python , например

  & gt; & gt; & gt; & gt;  sys.path.append ('/ path / to / django / trunk') & gt; & gt; & gt; & gt; & gt;  sys.path.insert (0, '/ path / to / django / trunk')  

Любая из этих команд должна добавить его к вашему пути.

1
ответ дан 6 August 2018 в 03:58

Хороший вопрос. Вы можете решить эту проблему с помощью python. Открытый интерпретатор python и

  Python 2.6 Введите «помощь», «авторское право», «кредиты» или «лицензия» для получения дополнительной информации.  & GT; & GT; & GT;  import sys & gt; & gt; & gt; & gt; & gt; & gt;  print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/ usr / lib  /python2.4/lib-tk ',' /usr/lib/python2.4/lib-dynload ',' /usr/local/lib/python2.4/site-packages ',' / usr / lib / python2.   

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python , например

  & gt; & gt; & gt; & gt;  sys.path.append ('/ path / to / django / trunk') & gt; & gt; & gt; & gt; & gt;  sys.path.insert (0, '/ path / to / django / trunk')  

Любая из этих команд должна добавить его к вашему пути.

1
ответ дан 7 August 2018 в 21:56

Хороший вопрос. Вы можете решить эту проблему с помощью python. Открытый интерпретатор python и

  Python 2.6 Введите «помощь», «авторское право», «кредиты» или «лицензия» для получения дополнительной информации.  & GT; & GT; & GT;  import sys & gt; & gt; & gt; & gt; & gt; & gt;  print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/ usr / lib  /python2.4/lib-tk ',' /usr/lib/python2.4/lib-dynload ',' /usr/local/lib/python2.4/site-packages ',' / usr / lib / python2.   

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python , например

  & gt; & gt; & gt; & gt;  sys.path.append ('/ path / to / django / trunk') & gt; & gt; & gt; & gt; & gt;  sys.path.insert (0, '/ path / to / django / trunk')  

Любая из этих команд должна добавить его к вашему пути.

1
ответ дан 10 August 2018 в 10:11

Хороший вопрос. Вы можете решить эту проблему с помощью python. Открытый интерпретатор python и

  Python 2.6 Введите «помощь», «авторское право», «кредиты» или «лицензия» для получения дополнительной информации.  & GT; & GT; & GT;  import sys & gt; & gt; & gt; & gt; & gt; & gt;  print sys.path ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/ usr / lib  /python2.4/lib-tk ',' /usr/lib/python2.4/lib-dynload ',' /usr/local/lib/python2.4/site-packages ',' / usr / lib / python2.   

Чтобы изменить путь, просто добавьте / добавьте записи в sys.path, который является обычным списком Python , например

  & gt; & gt; & gt; & gt;  sys.path.append ('/ path / to / django / trunk') & gt; & gt; & gt; & gt; & gt;  sys.path.insert (0, '/ path / to / django / trunk')  

Любая из этих команд должна добавить его к вашему пути.

1
ответ дан 13 August 2018 в 16:32
  • 1
    Ну, по крайней мере, наши ответы не являются полностью избыточными. ;) – belacqua 26 February 2011 в 22:55
  • 2
    за то, что он хочет сделать; это правильный способ сделать это. поэтому по крайней мере некоторые из наших ответов не совсем ошибочны. :П – myusuf3 27 February 2011 в 00:14
  • 3
    @dustyprogrammer Хм, я считаю, что часть моей информации была неправильной, по крайней мере, согласно python.org. Я заменил эту информацию и расширил ее. Я не пользователь django, поэтому я добавил пару ссылок на django-centric. – belacqua 27 February 2011 в 01:22
  • 4
    @jgbelacqua haha ​​копирует и вставляет вещи из Google, вы получите необходимую информацию даже без понимания. Теперь кто копирует кого? :) – myusuf3 27 February 2011 в 10:19
  • 5
    @dusty Я «копирую». python.org и другие ссылки, которые я цитировал, но пытаюсь использовать их в терминах, которые полезны для ОП и понятны мне. Я не уверен, почему вы считаете нужным оскорблять. – belacqua 27 February 2011 в 10:55