python
エラー === Deploying to 'test'... i deploying functions, hosting i functions: ensuring necessary APIs are enabled... ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading... Error: Error parsi…
ipythonを起動したら自動的に読み込んでくれるファイルの場所は ~/.ipython/profile_default/startup/00-test.pyといった形で書く。 辞書順に読み込むため、番号で管理するとわかりやすい 例えば、test.py import sys, os import readline import json impor…
サンプルコード 省略 plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0) # 右上に出す plt.subplots_adjust(left = 0.1, right = 0.7) # ここで、図がキャンバス内に収まるように調整する
サンプルコード from xml.dom import minidom 省略 xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml(indent=" ") with open("xml.xml", "w") as f: f.write(xmlstr) 参考 https://stackoverflow.com/questions/28813876/how-do-i-get-pythons-…
モデルの保存 # モデルの保存 json_model = model.to_json() with open("model.json", "w") as f json.dump(text, f) # パラメータの保存 model.save_weights("param.hdf5") 保存したモデルの読み込み from keras.models import model_from_json # モデルの…
サンプルコード import xml.etree.ElementTree as ET tree = ET.ElementTree(file="file.xml") # xmlを読み込む root = tree.getroot() element = ET.Element("vType") # 要素の作成 element.set("A", "a") # 属性の追加 root.insert(0, element) # 作成した…
oandpyをpipでインストールする方法 pip install git+https://github.com/oanda/oandapy.git
import random random.randint(a,b) # a以上b未満のランダムな整数を返す
環境 ubuntu16.04 python 3.4で動作 インストール方法 pip install Cython==0.26 pip install kivy
import random random.randint(a,b) # a以上b未満のランダムな整数を返す
以下コード例 import collections dct = {2:3, 1:89, 4:5, 3:0} new_dict = collections.OrderedDict(sorted(dct.items())) new_dict # => OrderedDict([(1, 89), (2, 3), (3, 0), (4, 5)]) new_dict.keys() # => odict_keys([1, 2, 3, 4]) new_dict.values(…
例:x軸と底が2の対数軸にしたい時には以下を追加する plt.xscale("log", basex=2)
import os paths = os.listdir(root_path)
問題 実験を回して 次の日に確認したら、 以下のようなエラー文をはいてpythonが落ちていた。。。。 sqlite3.DatabaseError: database disk image is malformed 解決策(暫定) 暫定の解決法としては、 ~/.ipython/profile_default/history.sqlite を削除し、…
pip install pytest pip install pytest-cov
エラー usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --cov=app --cov-report=html --cov-report=html 対処 以下のpytest-covをインストールしたら、エラーが解消された pip install pytest-cov
import os, sys print(os.getcwd()) sys.path.append(os.getcwd())
https://github.com/deepmind/pysc2/ のREADMEを参考に READMEにあるようにStarcraftをインストールする。 READMEにリンクされているBattle.netからStarcraftをインストールする この時にはログインが必要 デフォルトでc:/Program File(x86)/StarCraft Ⅱにイ…
下記のリンクに書いてあるように、mongod.serviceを作成する https://qiita.com/pelican/items/bb9b5290bb73acedc282 mongodbの起動 sudo mongodb 後は以下のコマンドでmongodbにアクセス mongo
課題 pymongoから、mlabで作成したデータベースにアクセスしようとした際に 以下のようなエラー pymongo.errors.OperationFailure: Authentication failed. 対処 1. ユーザーを作成 以下を参考に、アカウントを自分で作ってみた http://sh-yoshida.hatenablo…
課題 mpi4pyをインストールしようとしたら、 pip install mpi4py <省略> Failed building wheel for mpi4py <省略> 上記のようなエラーが発生し、インストールできなかった。 対処 以下のようにlibopenmpi-devをインストールしたあとに、mpi4pyを再度インス…
エラー内容 pythonのwebアプリをherokuにデプロイしようとした際に以下のようなエラー. Could not find a version that satisfies the requirement pkg-resources==0.0.0 対処法 requirement.txtから pkg-resources==0.0.0 を削除した後に,もう一度push 参考…
Flask使ってWebアプリ作りたいと思って, 少し調べて,有用だと思ったサイト一覧 Flask入門 https://qiita.com/zaburo/items/5091041a5afb2a7dffc8 Flaskアプリをherokuにデプロイ https://qiita.com/sqrtxx/items/2ae41d5685e07c16eda5 https://qiita.com/msr…
EnegyPlusのインストール方法 https://energyplus.net/downloads のLinuxのボタンをクリックし、シェルスクリプトをダウンロード 端末から sudo sh ダウンロードしたファイル pythonからEnegyPlusを操作できる「eppy」をインストール pip install eppy Enegy…
ipdbを用いて、複数行に渡るコードを実行しようと した時に起きたエラー。 対処 そもそも複数行で記述できないのかもしれない。。 結局以下のように一行で書くしかないかも for d in dir(request): print d 参考 https://stackoverflow.com/questions/977780…
エラー内容 python manage.py shell >>> from blog.models import Post >>> Post.objects.all() 省略 django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documen…
以下の二つのサイトが参考になった。 PythonでSlackbotを作る(1) – ビットログ qiita.com
pycharm上でjupyterを実行する時に、 urlとauthentication tokenを求められた。 そのurlとauthentication tokenは、端末で以下のコマンドを打つことで 調べることができる jupyter notebook list
pandasで単純移動平均を求めるやり方のメモ サンプルコード import pandas as pd sample_list = [0,1,2,3,4,5] sample_series = pd.Series(sample_list) average = sample_series.rolling(window=2).mean() print(average) 出力結果 0 NaN 1 0.5 2 1.5 3 2.5…
以下の図のx軸、y軸を消してみる コードと軸を削除したい図 %matplotlib inline from pylab import * import matplotlib.pyplot as plt fig,ax = plt.subplots() x_list = [0,1,2] y_list = [0,0,0] ax.scatter(x_list,y_list) 以下のコードで各軸を削除する…