You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2020/11/26 09:55:42 UTC

[iotdb] branch test_pip created (now 3e79958)

This is an automated email from the ASF dual-hosted git repository.

hxd pushed a change to branch test_pip
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 3e79958  refactor python client structure

This branch includes the following new commits:

     new e5b79b2  fix python path
     new 3e79958  refactor python client structure

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 02/02: refactor python client structure

Posted by hx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch test_pip
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 3e79958550d30851ae46f4d94ec4858bb3bb0dd6
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Thu Nov 26 17:52:14 2020 +0800

    refactor python client structure
---
 client-py/compile.bat                              | 29 --------------
 client-py/compile.sh                               | 28 -------------
 client-py/pom.xml                                  |  4 +-
 client-py/pypi/README.md                           | 34 ++++++++++------
 client-py/readme.md                                | 46 +++++++++++++---------
 client-py/src/SessionExample.py                    | 14 +------
 client-py/src/__init__.py                          | 18 ---------
 client-py/src/{ => iotdb}/Session.py               | 16 +++-----
 client-py/src/iotdb/__init__.py                    |  0
 client-py/src/{ => iotdb}/utils/Field.py           |  0
 client-py/src/{ => iotdb}/utils/IoTDBConstants.py  |  0
 client-py/src/{ => iotdb}/utils/IoTDBRpcDataSet.py |  2 +-
 client-py/src/{ => iotdb}/utils/RowRecord.py       |  0
 client-py/src/{ => iotdb}/utils/SessionDataSet.py  |  0
 client-py/src/{ => iotdb}/utils/Tablet.py          |  0
 client-py/src/{ => iotdb}/utils/__init__.py        |  0
 pom.xml                                            |  2 +-
 thrift/src/main/thrift/cluster.thrift              |  1 +
 thrift/src/main/thrift/rpc.thrift                  |  1 +
 thrift/src/main/thrift/sync.thrift                 |  1 +
 20 files changed, 63 insertions(+), 133 deletions(-)

diff --git a/client-py/compile.bat b/client-py/compile.bat
deleted file mode 100644
index 7b8532f..0000000
--- a/client-py/compile.bat
+++ /dev/null
@@ -1,29 +0,0 @@
-@REM
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements.  See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership.  The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License.  You may obtain a copy of the License at
-@REM
-@REM     http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied.  See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM
-
-@echo off
-set THRIFT_EXE=D:\software\Thrift\thrift-0.13.0.exe
-set BAT_DIR=%~dp0
-set THRIFT_SCRIPT=%BAT_DIR%..\thrift\src\main\thrift\rpc.thrift
-set THRIFT_OUT=%BAT_DIR%target\iotdb
-
-rmdir /Q /S %THRIFT_OUT%
-mkdir -p %THRIFT_OUT%
-
-%THRIFT_EXE% -gen py -out %THRIFT_OUT%  %THRIFT_SCRIPT%
diff --git a/client-py/compile.sh b/client-py/compile.sh
deleted file mode 100644
index 63426c6..0000000
--- a/client-py/compile.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-export THRIFT_EXE=thrift
-export SH_DIR=$(dirname $0)/
-export THRIFT_SCRIPT=${SH_DIR}../thrift/src/main/thrift/rpc.thrift
-export THRIFT_OUT=${SH_DIR}target/iotdb
-
-rm -rf ${THRIFT_OUT}
-mkdir -p ${THRIFT_OUT}
-${THRIFT_EXE} -gen py -out ${THRIFT_OUT}  ${THRIFT_SCRIPT}
diff --git a/client-py/pom.xml b/client-py/pom.xml
index 267a68a..8921a87 100644
--- a/client-py/pom.xml
+++ b/client-py/pom.xml
@@ -57,7 +57,7 @@
                         </goals>
                         <configuration>
                             <encoding>utf-8</encoding>
-                            <outputDirectory>${project.build.directory}/pypi/iotdb_session</outputDirectory>
+                            <outputDirectory>${project.build.directory}/pypi/</outputDirectory>
                             <resources>
                                 <resource>
                                     <directory>${basedir}/../thrift/target/generated-sources-python</directory>
@@ -94,7 +94,7 @@
                         </goals>
                         <configuration>
                             <encoding>utf-8</encoding>
-                            <outputDirectory>${project.build.directory}/pypi/iotdb_session</outputDirectory>
+                            <outputDirectory>${project.build.directory}/pypi/</outputDirectory>
                             <resources>
                                 <resource>
                                     <directory>${basedir}/src/</directory>
diff --git a/client-py/pypi/README.md b/client-py/pypi/README.md
index 590aac8..dc7182c 100644
--- a/client-py/pypi/README.md
+++ b/client-py/pypi/README.md
@@ -32,11 +32,11 @@
 [![IoTDB Website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=iotdb-website)](https://iotdb.apache.org/)
 
 
-Apache IoTDB (incubating) (Database for Internet of Things) is an integrated data management engine designed for
-timeseries data. It provides users with services for data collection, storage and analysis. Due to its light-weight
-architecture, high performance and rich feature set together with its deep integration with Apache Hadoop and Spark,
-Apache IoTDB (incubating) can meet the requirements of massive data storage, high-speed data ingestion and complex data
-analysis in the IoT industrial fields.
+Apache IoTDB (Database for Internet of Things) is an IoT native database with high performance for 
+data management and analysis, deployable on the edge and the cloud. Due to its light-weight 
+architecture, high performance and rich feature set together with its deep integration with 
+Apache Hadoop, Spark and Flink, Apache IoTDB can meet the requirements of massive data storage, 
+high-speed data ingestion and complex data analysis in the IoT industrial fields.
 
 
 # Apache IoTDB Python Client API
@@ -51,15 +51,23 @@ You have to install thrift (>=0.13) before using the package.
 
 First, download the package: `pip3 install apache-iotdb`
 
-You can get an example of using the package to read and write data at here: [Example](https://github.com/apache/iotdb/blob/rel/0.10/client-py/src/SessionExample.py)
+You can get an example of using the package to read and write data at here: [Example](https://github.com/apache/iotdb/blob/rel/0.11/client-py/src/SessionExample.py)
 
 (you need to add `import iotdb` in the head of the file)
 
-# DISCLAIMER
+Or:
 
-Apache IoTDB is an effort undergoing incubation at The Apache Software Foundation (ASF).
-Incubation is required of all newly accepted projects until a further review indicates that the
-infrastructure, communications, and decision making process have stabilized in a manner consistent
-with other successful ASF projects. While incubation status is not necessarily a reflection of the
-completeness or stability of the code, it does indicate that the project has yet to be fully
-endorsed by the ASF.
\ No newline at end of file
+```python
+
+from iotdb.Session import Session
+
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = 'root'
+password_ = 'root'
+session = Session(ip, port_, username_, password_)
+session.open(False)
+zone = session.get_time_zone()
+session.close()
+
+```
\ No newline at end of file
diff --git a/client-py/readme.md b/client-py/readme.md
index abdcb7f..113a334 100644
--- a/client-py/readme.md
+++ b/client-py/readme.md
@@ -33,29 +33,39 @@ tutorial of installation, eventually, you should have a thrift executable.
 http://thrift.apache.org/docs/install/
 ```
 
-## Compile the thrift library
-If you have added Thrift executable into your path, you may just run `client-py/compile.sh` or
- `client-py\compile.bat`, or you will have to modify it to set variable `THRIFT_EXE` to point to
-your executable. This will generate thrift sources under folder `target`, you can add it to your
-`PYTHONPATH` so that you would be able to use the library in your code. Notice that the scripts
-locate the thrift source file by relative path, so if you move the scripts else where, they are
-no longer valid.
-
-Optionally, if you know the basic usage of thrift, you can only download the thrift source file in
-`thrift\src\main\thrift\rpc.thrift`, and simply use `thrift -gen py -out ./target/iotdb rpc.thrift` 
-to generate the python library.
+## Compile the thrift library and Debug
+
+In the root of IoTDB's source code folder,  run `mvn generate-sources -pl client-py -am`.
+
+Then a complete project will be generated at `client-py/target/pypi` folder. 
+But !BE CAUTIOUS!
+All your modifications in `client-py/target/pypi` must be copied manually to `client-py/src/` folder.
+Otherwise once you run `mvn clean`, you will lose all your effort.
+
+Or, you can also copy `client-py/target/pypi/iotdb/thrift` folder to `client-py/src/thrift`, then the 
+`src` folder will become also a complete python project. 
+But !BE CAUTIOUS!
+Do not upload `client-py/src/thrift` to the git repo.
+
 
 ## Session Client & Example
-We packed up the Thrift interface in `client-py/src/Session.py` (similar with its Java counterpart), also provided 
+We packed up the Thrift interface in `client-py/src/iotdb/Session.py` (similar with its Java counterpart), also provided 
 an example file `client-py/src/SessionExample.py` of how to use the session module. please read it carefully.
 
-## How to Debug
 
-To debug the python API module, run `mvn generate-sources -pl thrift,client-py`
+Or, another simple example:
 
-Then, go to target/pypi to get the complete projects.
+```$python
 
-But !BE CAUTIOUS!
-All your modifications in target/pypi must be copied manually to src/ folder.
-Otherwise once you run `mvn clean`, you will lose all your effort.
+from iotdb.Session import Session
+
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = 'root'
+password_ = 'root'
+session = Session(ip, port_, username_, password_)
+session.open(False)
+zone = session.get_time_zone()
+session.close()
 
+```
\ No newline at end of file
diff --git a/client-py/src/SessionExample.py b/client-py/src/SessionExample.py
index 35e57bd..9eac78f 100644
--- a/client-py/src/SessionExample.py
+++ b/client-py/src/SessionExample.py
@@ -16,20 +16,10 @@
 # under the License.
 #
 
-import sys
 # Uncomment the following line to use apache-iotdb module installed by pip3
 
-# for debug
-# sys.path.append("./utils")
-# from IoTDBConstants import *
-# from Tablet import Tablet
-# from Session import Session
-
-# for package
-from iotdb_session.utils.IoTDBConstants import *
-from iotdb_session.utils.Tablet import Tablet
-from iotdb_session.Session import Session
-
+from iotdb.Session import Session
+from iotdb.utils import Tablet
 
 # creating session connection.
 ip = "127.0.0.1"
diff --git a/client-py/src/__init__.py b/client-py/src/__init__.py
deleted file mode 100644
index a4797b6..0000000
--- a/client-py/src/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
diff --git a/client-py/src/Session.py b/client-py/src/iotdb/Session.py
similarity index 97%
rename from client-py/src/Session.py
rename to client-py/src/iotdb/Session.py
index 1fe8e41..839ba95 100644
--- a/client-py/src/Session.py
+++ b/client-py/src/iotdb/Session.py
@@ -16,24 +16,18 @@
 # under the License.
 #
 
-import sys
 import struct
+import sys
 import time
 
-#sys.path.append("../../thrift/target/generated-sources-python")
-sys.path.append("./utils")
-
-# for package
-from .utils.IoTDBConstants import *
-from .utils.SessionDataSet import SessionDataSet
+from .utils import SessionDataSet
 
 from thrift.protocol import TBinaryProtocol, TCompactProtocol
 from thrift.transport import TSocket, TTransport
 
-from .iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertRecordReq, TSInsertTabletReq, \
-     TSExecuteStatementReq, TSOpenSessionReq, TSQueryDataSet, TSFetchResultsReq, TSCloseOperationReq, \
-     TSCreateMultiTimeseriesReq, TSCloseSessionReq, TSInsertTabletsReq, TSInsertRecordsReq
-from .iotdb.rpc.ttypes import TSDeleteDataReq, TSProtocolVersion, TSSetTimeZoneReq
+from .thrift.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertRecordReq, TSInsertTabletReq, \
+     TSExecuteStatementReq, TSOpenSessionReq, TSCreateMultiTimeseriesReq, TSCloseSessionReq, TSInsertTabletsReq, TSInsertRecordsReq
+from .thrift.rpc.ttypes import TSDeleteDataReq, TSProtocolVersion, TSSetTimeZoneReq
 
 # for debug
 # from IoTDBConstants import *
diff --git a/client-py/src/iotdb/__init__.py b/client-py/src/iotdb/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/client-py/src/utils/Field.py b/client-py/src/iotdb/utils/Field.py
similarity index 100%
rename from client-py/src/utils/Field.py
rename to client-py/src/iotdb/utils/Field.py
diff --git a/client-py/src/utils/IoTDBConstants.py b/client-py/src/iotdb/utils/IoTDBConstants.py
similarity index 100%
rename from client-py/src/utils/IoTDBConstants.py
rename to client-py/src/iotdb/utils/IoTDBConstants.py
diff --git a/client-py/src/utils/IoTDBRpcDataSet.py b/client-py/src/iotdb/utils/IoTDBRpcDataSet.py
similarity index 99%
rename from client-py/src/utils/IoTDBRpcDataSet.py
rename to client-py/src/iotdb/utils/IoTDBRpcDataSet.py
index 6aa2fa3..21c2f0e 100644
--- a/client-py/src/utils/IoTDBRpcDataSet.py
+++ b/client-py/src/iotdb/utils/IoTDBRpcDataSet.py
@@ -28,7 +28,7 @@ path = dirname(dirname(abspath(__file__)))
 sys.path.append(path)
 
 from thrift.transport import TTransport
-from iotdb.rpc.TSIService import TSFetchResultsReq, TSCloseOperationReq
+from iotdb.thrift.rpc.TSIService import TSFetchResultsReq, TSCloseOperationReq
 
 
 class IoTDBRpcDataSet(object):
diff --git a/client-py/src/utils/RowRecord.py b/client-py/src/iotdb/utils/RowRecord.py
similarity index 100%
rename from client-py/src/utils/RowRecord.py
rename to client-py/src/iotdb/utils/RowRecord.py
diff --git a/client-py/src/utils/SessionDataSet.py b/client-py/src/iotdb/utils/SessionDataSet.py
similarity index 100%
rename from client-py/src/utils/SessionDataSet.py
rename to client-py/src/iotdb/utils/SessionDataSet.py
diff --git a/client-py/src/utils/Tablet.py b/client-py/src/iotdb/utils/Tablet.py
similarity index 100%
rename from client-py/src/utils/Tablet.py
rename to client-py/src/iotdb/utils/Tablet.py
diff --git a/client-py/src/utils/__init__.py b/client-py/src/iotdb/utils/__init__.py
similarity index 100%
rename from client-py/src/utils/__init__.py
rename to client-py/src/iotdb/utils/__init__.py
diff --git a/pom.xml b/pom.xml
index fd734d4..999dc91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -997,7 +997,7 @@
                                     <generator>py</generator>
                                     <thriftExecutable>${thrift.exec.absolute.path}</thriftExecutable>
                                     <thriftSourceRoot>${basedir}/src/main/thrift</thriftSourceRoot>
-                                    <outputDirectory>${project.build.directory}/generated-sources-python/iotdb</outputDirectory>
+                                    <outputDirectory>${project.build.directory}/generated-sources-python/</outputDirectory>
                                 </configuration>
                             </execution>
                             <execution>
diff --git a/thrift/src/main/thrift/cluster.thrift b/thrift/src/main/thrift/cluster.thrift
index a85e090..6e96d86 100644
--- a/thrift/src/main/thrift/cluster.thrift
+++ b/thrift/src/main/thrift/cluster.thrift
@@ -19,6 +19,7 @@
 
 include "rpc.thrift"
 namespace java org.apache.iotdb.cluster.rpc.thrift
+namespace py iotdb.thrift.cluster
 
 typedef i32 int 
 typedef i16 short
diff --git a/thrift/src/main/thrift/rpc.thrift b/thrift/src/main/thrift/rpc.thrift
index 7b83144..4f412bf 100644
--- a/thrift/src/main/thrift/rpc.thrift
+++ b/thrift/src/main/thrift/rpc.thrift
@@ -17,6 +17,7 @@
  * under the License.
  */
 namespace java org.apache.iotdb.service.rpc.thrift
+namespace py iotdb.thrift.rpc
 
 // The return status code and message in each response.
 struct TSStatus {
diff --git a/thrift/src/main/thrift/sync.thrift b/thrift/src/main/thrift/sync.thrift
index 3e243f4..2c67353 100755
--- a/thrift/src/main/thrift/sync.thrift
+++ b/thrift/src/main/thrift/sync.thrift
@@ -17,6 +17,7 @@
  * under the License.
  */
 namespace java org.apache.iotdb.service.sync.thrift
+namespace py iotdb.thrift.sync
 
 struct SyncStatus{
   1:required i32 code


[iotdb] 01/02: fix python path

Posted by hx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch test_pip
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit e5b79b2d11670fbbffa07518961f171549d4f746
Author: 151250176 <15...@smail.nju.edu.cn>
AuthorDate: Thu Nov 26 11:10:38 2020 +0800

    fix python path
---
 client-py/src/Session.py               | 21 +++++++++++++++++----
 client-py/src/SessionExample.py        | 17 ++++++++++++-----
 client-py/src/utils/Field.py           |  5 ++++-
 client-py/src/utils/IoTDBRpcDataSet.py | 11 ++++++++++-
 client-py/src/utils/RowRecord.py       |  8 ++++++--
 client-py/src/utils/SessionDataSet.py  | 16 ++++++++++++----
 client-py/src/utils/Tablet.py          |  7 ++++++-
 7 files changed, 67 insertions(+), 18 deletions(-)

diff --git a/client-py/src/Session.py b/client-py/src/Session.py
index 93579ce..1fe8e41 100644
--- a/client-py/src/Session.py
+++ b/client-py/src/Session.py
@@ -23,16 +23,29 @@ import time
 #sys.path.append("../../thrift/target/generated-sources-python")
 sys.path.append("./utils")
 
-from IoTDBConstants import *
-from SessionDataSet import SessionDataSet
+# for package
+from .utils.IoTDBConstants import *
+from .utils.SessionDataSet import SessionDataSet
 
 from thrift.protocol import TBinaryProtocol, TCompactProtocol
 from thrift.transport import TSocket, TTransport
 
-from iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertRecordReq, TSInsertTabletReq, \
+from .iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertRecordReq, TSInsertTabletReq, \
      TSExecuteStatementReq, TSOpenSessionReq, TSQueryDataSet, TSFetchResultsReq, TSCloseOperationReq, \
      TSCreateMultiTimeseriesReq, TSCloseSessionReq, TSInsertTabletsReq, TSInsertRecordsReq
-from iotdb.rpc.ttypes import TSDeleteDataReq, TSProtocolVersion, TSSetTimeZoneReq
+from .iotdb.rpc.ttypes import TSDeleteDataReq, TSProtocolVersion, TSSetTimeZoneReq
+
+# for debug
+# from IoTDBConstants import *
+# from SessionDataSet import SessionDataSet
+#
+# from thrift.protocol import TBinaryProtocol, TCompactProtocol
+# from thrift.transport import TSocket, TTransport
+#
+# from iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertRecordReq, TSInsertTabletReq, \
+#      TSExecuteStatementReq, TSOpenSessionReq, TSQueryDataSet, TSFetchResultsReq, TSCloseOperationReq, \
+#      TSCreateMultiTimeseriesReq, TSCloseSessionReq, TSInsertTabletsReq, TSInsertRecordsReq
+# from iotdb.rpc.ttypes import TSDeleteDataReq, TSProtocolVersion, TSSetTimeZoneReq
 
 
 class Session(object):
diff --git a/client-py/src/SessionExample.py b/client-py/src/SessionExample.py
index 5ad0882..35e57bd 100644
--- a/client-py/src/SessionExample.py
+++ b/client-py/src/SessionExample.py
@@ -18,11 +18,18 @@
 
 import sys
 # Uncomment the following line to use apache-iotdb module installed by pip3
-#import iotdb
-sys.path.append("./utils")
-from IoTDBConstants import *
-from Tablet import Tablet
-from Session import Session
+
+# for debug
+# sys.path.append("./utils")
+# from IoTDBConstants import *
+# from Tablet import Tablet
+# from Session import Session
+
+# for package
+from iotdb_session.utils.IoTDBConstants import *
+from iotdb_session.utils.Tablet import Tablet
+from iotdb_session.Session import Session
+
 
 # creating session connection.
 ip = "127.0.0.1"
diff --git a/client-py/src/utils/Field.py b/client-py/src/utils/Field.py
index 7b5fea5..55d1e33 100644
--- a/client-py/src/utils/Field.py
+++ b/client-py/src/utils/Field.py
@@ -16,8 +16,11 @@
 # under the License.
 #
 
-from IoTDBConstants import TSDataType
+# for package
+from .IoTDBConstants import TSDataType
 
+# for debug
+# from IoTDBConstants import TSDataType
 
 class Field(object):
 
diff --git a/client-py/src/utils/IoTDBRpcDataSet.py b/client-py/src/utils/IoTDBRpcDataSet.py
index f712c98..6aa2fa3 100644
--- a/client-py/src/utils/IoTDBRpcDataSet.py
+++ b/client-py/src/utils/IoTDBRpcDataSet.py
@@ -16,7 +16,16 @@
 # under the License.
 #
 
-from IoTDBConstants import *
+# for package
+from .IoTDBConstants import *
+
+# for debug
+# from IoTDBConstants import *
+
+import sys
+from os.path import dirname, abspath
+path = dirname(dirname(abspath(__file__)))
+sys.path.append(path)
 
 from thrift.transport import TTransport
 from iotdb.rpc.TSIService import TSFetchResultsReq, TSCloseOperationReq
diff --git a/client-py/src/utils/RowRecord.py b/client-py/src/utils/RowRecord.py
index 78e0362..46d810e 100644
--- a/client-py/src/utils/RowRecord.py
+++ b/client-py/src/utils/RowRecord.py
@@ -16,9 +16,13 @@
 # under the License.
 #
 
-from IoTDBConstants import TSDataType
-from Field import Field
+# for package
+from .IoTDBConstants import TSDataType
+from .Field import Field
 
+# for debug
+# from IoTDBConstants import TSDataType
+# from Field import Field
 
 class RowRecord(object):
 
diff --git a/client-py/src/utils/SessionDataSet.py b/client-py/src/utils/SessionDataSet.py
index 92662cc..91b1989 100644
--- a/client-py/src/utils/SessionDataSet.py
+++ b/client-py/src/utils/SessionDataSet.py
@@ -16,10 +16,18 @@
 # under the License.
 #
 
-from IoTDBConstants import TSDataType
-from IoTDBRpcDataSet import IoTDBRpcDataSet
-from Field import Field
-from RowRecord import RowRecord
+# for package
+from .IoTDBConstants import TSDataType
+from .IoTDBRpcDataSet import IoTDBRpcDataSet
+from .Field import Field
+from .RowRecord import RowRecord
+
+# for debug
+# from IoTDBConstants import TSDataType
+# from IoTDBRpcDataSet import IoTDBRpcDataSet
+# from Field import Field
+# from RowRecord import RowRecord
+
 import struct
 
 
diff --git a/client-py/src/utils/Tablet.py b/client-py/src/utils/Tablet.py
index 51798a4..cdb0c21 100644
--- a/client-py/src/utils/Tablet.py
+++ b/client-py/src/utils/Tablet.py
@@ -16,7 +16,12 @@
 # under the License.
 #
 
-from IoTDBConstants import *
+# for package
+from .IoTDBConstants import *
+
+# for debug
+# from IoTDBConstants import *
+
 import struct