我正在使用Windows,并且有一个这样的目录:
# Change Python path used by the server.
WSGIPythonPath “/EquipmentCalibration”
# Make calls to http://localhost/ refer to the Python/WSGI-script located at the specified location.
WSGIScriptAlias / /EquipmentCalibration/equipcal/wsgi.py
# Make calls to http://localhost/static refer to the specified folder.
Alias /static/ /EquipmentCalibration/static
Alias /media/ /EquipmentCalibration/media
<Directory /EquipmentCalibration/static>
Require all granted
</Directory>
<Directory /EquipmentCalibration/media>
Require all granted
</Directory>
<Directory /EquipmentCalibration/equipcale>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
我使用pip来安装包...并且pip list显示已安装的包并指向dir结构的顶部。
[Thu Sep 29 15:05:25.171920 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Thu Sep 29 15:05:25.171920 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Thu Sep 29 15:05:25.171920 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 7524
[Thu Sep 29 15:05:25.500078 2016] [wsgi:warn] [pid 7524:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 15:05:25.500078 2016] [wsgi:warn] [pid 7524:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 15:05:26.171978 2016] [mpm_winnt:notice] [pid 7524:tid 456] AH00354: Child: Starting 64 worker threads.
[Thu Sep 29 15:05:27.174429 2016] [mpm_winnt:notice] [pid 7636:tid 456] AH00364: Child: All worker threads have exited.
[Thu Sep 29 15:05:29.923754 2016] [authz_core:error] [pid 7524:tid 1108] [client ::1:55483] AH01630: client denied by server configuration: C:/EquipmentCalibration/equipcal/wsgi.py
:
troopcalc/
setup.py
troopcalc/
__init__.py
troopcalc.py
troopcfg.py
tests/
__init__.py
test_troopcalc.py
test_troopcfg.py
troopcfg.py
:
class TroopCfg(object):
...
troopcalc.py
:
from troopcalc.troopcfg import TroopCfg
如果我运行setup.py
,我会收到以下信息:
from setuptools import setup
setup(name='troopcalc',
version='0.1',
description='Calculates troop distribution',
url='...',
author='Randell ...',
author_email='...',
packages=['troopcalc', 'troopcalc.tests', 'troopcalc.data'],
package_dir={'troopcalc': 'troopcalc', 'troopcalc.tests': 'troopcalc/tests', 'troopcalc.data': 'troopcalc/data'},
package_data={'troopcalc.data': ['*.json']},
)
pip说这是一个软件包,但是python说它不是。目标不是使用绝对路径。我错过了什么?
感谢。
答案 0 :(得分:1)
如果我运行
python .\troopcalc.py
,我会收到以下信息:
嗯,是的。 Python认为troopcalc
是troopcalc.py
,因为它位于sys.path
的目录中。
python -m troopcalc.troopcalc