CentOS8にPythonのライブラリを追加して実行する方法の続き
/investigation/python-library-add-pip/
エラー:「UnicodeDecodeError: ‘utf-8’」
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python3 chart_05.py | |
/usr/local/lib/python3.6/site-packages/mpl_finance.py:22: DeprecationWarning: | |
================================================================= | |
WARNING: mpl_finance is deprecated: | |
Please use mplfinance instead (no hyphen, no underscore). | |
To install: pip install --upgrade mplfinance | |
For more information, see: https://pypi.org/project/mplfinance/ | |
================================================================= | |
category=DeprecationWarning) | |
Traceback (most recent call last): | |
File "chart_05.py", line 73, in <module> | |
cf = myf.get_config() | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 548, in get_config | |
cf = pd.read_csv(config, quotechar='"', header=38, index_col=0) | |
File "/usr/local/lib64/python3.6/site-packages/pandas/io/parsers.py", line 688, in read_csv | |
return _read(filepath_or_buffer, kwds) | |
File "/usr/local/lib64/python3.6/site-packages/pandas/io/parsers.py", line 454, in _read | |
parser = TextFileReader(fp_or_buf, **kwds) | |
File "/usr/local/lib64/python3.6/site-packages/pandas/io/parsers.py", line 948, in __init__ | |
self._make_engine(self.engine) | |
File "/usr/local/lib64/python3.6/site-packages/pandas/io/parsers.py", line 1180, in _make_engine | |
self._engine = CParserWrapper(self.f, **self.options) | |
File "/usr/local/lib64/python3.6/site-packages/pandas/io/parsers.py", line 2010, in __init__ | |
self._reader = parsers.TextReader(src, **kwds) | |
File "pandas/_libs/parsers.pyx", line 537, in pandas._libs.parsers.TextReader.__cinit__ | |
File "pandas/_libs/parsers.pyx", line 711, in pandas._libs.parsers.TextReader._get_header | |
File "pandas/_libs/parsers.pyx", line 905, in pandas._libs.parsers.TextReader._tokenize_rows | |
File "pandas/_libs/parsers.pyx", line 2034, in pandas._libs.parsers.raise_parser_error | |
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 16: invalid start byte |
pip3 install –upgrade mplfinance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip3 install --upgrade mplfinance | |
WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead. | |
Requirement already up-to-date: mplfinance in /usr/local/lib/python3.6/site-packages | |
Requirement already up-to-date: pandas in /usr/local/lib64/python3.6/site-packages (from mplfinance) | |
Requirement already up-to-date: matplotlib in /usr/local/lib64/python3.6/site-packages (from mplfinance) | |
Requirement already up-to-date: python-dateutil>=2.7.3 in /usr/local/lib/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: pytz>=2017.2 in /usr/local/lib/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: numpy>=1.15.4 in /usr/local/lib64/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: pillow>=6.2.0 in /usr/local/lib64/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas->mplfinance) |
Successfully installed mplfinance-0.12.7a10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip3 install --upgrade mplfinance | |
WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead. | |
Collecting mplfinance | |
Downloading https://files.pythonhosted.org/packages/b3/db/b2546ef2e855a70ad33b00fcc80a2ee4f43116f60d6db1d0186618d8ad95/mplfinance-0.12.7a10-py3-none-any.whl (59kB) | |
100% |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 61kB 3.4MB/s | |
Requirement already up-to-date: pandas in /usr/local/lib64/python3.6/site-packages (from mplfinance) | |
Requirement already up-to-date: matplotlib in /usr/local/lib64/python3.6/site-packages (from mplfinance) | |
Requirement already up-to-date: pytz>=2017.2 in /usr/local/lib/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: python-dateutil>=2.7.3 in /usr/local/lib/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: numpy>=1.15.4 in /usr/local/lib64/python3.6/site-packages (from pandas->mplfinance) | |
Requirement already up-to-date: pillow>=6.2.0 in /usr/local/lib64/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib->mplfinance) | |
Requirement already up-to-date: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas->mplfinance) | |
Installing collected packages: mplfinance | |
Successfully installed mplfinance-0.12.7a10 |
エラー:「ModuleNotFoundError: No module named ‘mysql’」
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python3 chart_05.py | |
/usr/local/lib/python3.6/site-packages/mpl_finance.py:22: DeprecationWarning: | |
================================================================= | |
WARNING: mpl_finance is deprecated: | |
Please use mplfinance instead (no hyphen, no underscore). | |
To install: pip install --upgrade mplfinance | |
For more information, see: https://pypi.org/project/mplfinance/ | |
================================================================= | |
category=DeprecationWarning) | |
/var/www/tmp/chart_analytics/stock_data/nikkei_225.csv | |
gcode name | |
code | |
1332 35 日水 | |
1333 35 マルハニチロ | |
1605 37 国際石開帝石 | |
1925 41 ハウス | |
1928 41 積ハウス | |
... ... ... | |
9735 71 セコム | |
2432 71 ディーエヌエ | |
4324 71 電通グループ | |
9766 71 コナミHD | |
6098 71 リクルート | |
[225 rows x 2 columns] | |
Traceback (most recent call last): | |
File "chart_05.py", line 89, in <module> | |
sdata = myf.fetchDatas(code, start, end) # DBから株価データ取得 | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 456, in fetchDatas | |
conn = connectMysql() | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 442, in connectMysql | |
import mysql.connector as mydb | |
ModuleNotFoundError: No module named 'mysql' |
pip3 install mysql-connector-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip3 install mysql-connector-python | |
WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead. | |
Collecting mysql-connector-python | |
Downloading https://files.pythonhosted.org/packages/cc/ec/102bf59d0cdeb3b8fc82d6669bf96d57d133e44811ff57ad5e941bd8588d/mysql_connector_python-8.0.23-cp36-cp36m-manylinux1_x86_64.whl (18.0MB) | |
100% |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 18.1MB 113kB/s | |
Collecting protobuf>=3.0.0 (from mysql-connector-python) | |
Downloading https://files.pythonhosted.org/packages/d7/e8/bc878782a29afc80ef03345ff7a7c4071fbeedf58d5a9804469094df636b/protobuf-3.15.7-cp36-cp36m-manylinux1_x86_64.whl (1.0MB) | |
100% |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 1.0MB 1.8MB/s | |
Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.6/site-packages (from protobuf>=3.0.0->mysql-connector-python) | |
Installing collected packages: protobuf, mysql-connector-python | |
Successfully installed mysql-connector-python-8.0.23 protobuf-3.15.7 |
エラー:「Unknown database」
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python3 chart_05.py | |
/usr/local/lib/python3.6/site-packages/mpl_finance.py:22: DeprecationWarning: | |
================================================================= | |
WARNING: mpl_finance is deprecated: | |
Please use mplfinance instead (no hyphen, no underscore). | |
To install: pip install --upgrade mplfinance | |
For more information, see: https://pypi.org/project/mplfinance/ | |
================================================================= | |
category=DeprecationWarning) | |
/var/www/tmp/chart_analytics/stock_data/nikkei_225.csv | |
gcode name | |
code | |
1332 35 日水 | |
1333 35 マルハニチロ | |
1605 37 国際石開帝石 | |
1925 41 ハウス | |
1928 41 積ハウス | |
... ... ... | |
9735 71 セコム | |
2432 71 ディーエヌエ | |
4324 71 電通グループ | |
9766 71 コナミHD | |
6098 71 リクルート | |
[225 rows x 2 columns] | |
Traceback (most recent call last): | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 233, in _open_connection | |
self._cmysql.connect(**cnx_kwargs) | |
_mysql_connector.MySQLInterfaceError: Unknown database 'stocks' | |
During handling of the above exception, another exception occurred: | |
Traceback (most recent call last): | |
File "chart_05.py", line 89, in <module> | |
sdata = myf.fetchDatas(code, start, end) # DBから株価データ取得 | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 456, in fetchDatas | |
conn = connectMysql() | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 450, in connectMysql | |
database='stocks' | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/__init__.py", line 277, in connect | |
return CMySQLConnection(*args, **kwargs) | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 86, in __init__ | |
self.connect(**kwargs) | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/abstracts.py", line 1003, in connect | |
self._open_connection() | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 236, in _open_connection | |
sqlstate=exc.sqlstate) | |
mysql.connector.errors.ProgrammingError: 1049 (42000): Unknown database 'stocks' |
create database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mysql -u root -p -h localhost | |
Enter password: | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 2558 | |
Server version: 8.0.21 Source distribution | |
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. | |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> create database stocks; | |
Query OK, 1 row affected (0.01 sec) |
Table ” doesn’t exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python3 chart_05.py | |
/usr/local/lib/python3.6/site-packages/mpl_finance.py:22: DeprecationWarning: | |
================================================================= | |
WARNING: mpl_finance is deprecated: | |
Please use mplfinance instead (no hyphen, no underscore). | |
To install: pip install --upgrade mplfinance | |
For more information, see: https://pypi.org/project/mplfinance/ | |
================================================================= | |
category=DeprecationWarning) | |
/var/www/tmp/chart_analytics/stock_data/nikkei_225.csv | |
gcode name | |
code | |
1332 35 日水 | |
1333 35 マルハニチロ | |
1605 37 国際石開帝石 | |
1925 41 ハウス | |
1928 41 積ハウス | |
... ... ... | |
9735 71 セコム | |
2432 71 ディーエヌエ | |
4324 71 電通グループ | |
9766 71 コナミHD | |
6098 71 リクルート | |
[225 rows x 2 columns] | |
Traceback (most recent call last): | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 509, in cmd_query | |
raw_as_string=raw_as_string) | |
_mysql_connector.MySQLInterfaceError: Table 'stocks.s9104' doesn't exist | |
During handling of the above exception, another exception occurred: | |
Traceback (most recent call last): | |
File "chart_05.py", line 89, in <module> | |
sdata = myf.fetchDatas(code, start, end) # DBから株価データ取得 | |
File "/var/www/tmp/chart_analytics/lib/my_function.py", line 462, in fetchDatas | |
cur.execute(cnt_sql) | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/cursor_cext.py", line 276, in execute | |
raw_as_string=self._raw_as_string) | |
File "/usr/local/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 512, in cmd_query | |
sqlstate=exc.sqlstate) | |
mysql.connector.errors.ProgrammingError: 1146 (42S02): Table 'stocks.s9104' doesn't exist |