LoginSignup
1
0

More than 5 years have passed since last update.

家で Python2.7(32bit) の練習をしようぜ。

Last updated at Posted at 2018-09-02

覚えたくないんだが それがレガシーだから、レガシーを読まないとな。

Python (Command line) というのがあるが、これは頭に >>> が付くんだが、
コマンドプロンプトの python コマンドとは別もののようだ。

print("hello, world!!")

と打鍵、[Enter]。

hello, world!!

動いてはいるようだ。じゃあ次に 以下のコードを動かせるようにしたい。
ファイル名は setup.py

#########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################

"""Perform the initial setup of the application, by creating the auth
and settings database."""

import os
import sys
from pgadmin.model import db, Version, SCHEMA_VERSION as CURRENT_SCHEMA_VERSION

if sys.version_info[0] >= 3:
    import builtins
else:
    import __builtin__ as builtins

# Grab the SERVER_MODE if it's been set by the runtime
if 'SERVER_MODE' in globals():
    builtins.SERVER_MODE = globals()['SERVER_MODE']
else:
    builtins.SERVER_MODE = None

# We need to include the root directory in sys.path to ensure that we can
# find everything we need when running in the standalone runtime.
root = os.path.dirname(os.path.realpath(__file__))
if sys.path[0] != root:
    sys.path.insert(0, root)

from pgadmin import create_app

if __name__ == '__main__':
    # Configuration settings
    import config
    from pgadmin.model import SCHEMA_VERSION
    from pgadmin.setup import db_upgrade, create_app_data_directory

    config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
    if "PGADMIN_TESTING_MODE" in os. environ and \
            os.environ["PGADMIN_TESTING_MODE"] == "1":
        config.SQLITE_PATH = config.TEST_SQLITE_PATH

    create_app_data_directory(config)

    app = create_app()

    print(u"pgAdmin 4 - Application Initialisation")
    print(u"======================================\n")

    with app.app_context():
        # Run migration for the first time i.e. create database
        from config import SQLITE_PATH
        if not os.path.exists(SQLITE_PATH):
            db_upgrade(app)
        else:
            version = Version.query.filter_by(name='ConfigDB').first()
            schema_version = version.value

            # Run migration if current schema version is greater than the
            # schema version stored in version table
            if CURRENT_SCHEMA_VERSION >= schema_version:
                db_upgrade(app)

            # Update schema version to the latest
            if CURRENT_SCHEMA_VERSION > schema_version:
                version = Version.query.filter_by(name='ConfigDB').first()
                version.value = CURRENT_SCHEMA_VERSION
                db.session.commit()

コマンドプロンプトを管理者権限で開き、コマンドを実行してみる。

C:\Program Files (x86)\pgAdmin 4\v3\web>python setup.py
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    from pgadmin.model import db, Version, SCHEMA_VERSION as CURRENT_SCHEMA_VERSION
  File "C:\Program Files (x86)\pgAdmin 4\v3\web\pgadmin\__init__.py", line 18, in <module>
    from flask import Flask, abort, request, current_app, session, url_for
ImportError: No module named flask
>>> import os
>>> import sys
>>> from pgadmin.model import db, Version, SCHEMA_VERSION as CURRENT_SCHEMA_VERSION
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pgadmin.model

3行目で早くもエラー。

from pgadmin.model import db, Version, SCHEMA_VERSION as CURRENT_SCHEMA_VERSION

これは最初から入ってるわけではないのか?
pgAdmin4 をインストールしたときとか。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0