20210427のdockerに関する記事は10件です。

【自分用メモ】Kubernetesのよく使うリソースまとめ【初心者】

概要 PodやらDeploymentやら、k8sのリソースは種類がいっぱいあってよくわからないのでまとめてみる 基本的に以下の書籍の内容をなぞる Docker/Kubernetes 実践コンテナ入門 github: https://github.com/yoskeoka/gihyo-docker-kuberbetes Node k8sクラスタが最も大きいリソース単位 クラスタの管理下にNodeがある AWSでいうEC2のインスタンス $ kubectl get nodes でクラスタ内nodeを確認 Namespace クラスタ内ではnamespaceごとに仮想的なクラスタを作成できる。 namespaceの一覧を見るには $ kubectl get namespace と打てばいい。 今後出てくるコマンドでnamespaceを指定したい場合は基本的に -n {namespame} のオプションをつければどうにかなる。 Pod 1個以上のコンテナの集合体 例 myPod.yaml apiVersion: v1 kind: Pod metadata: name: my-echo spec: containers: - name: nginx image: gihyodockernginx ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080 kindでリソースの種類を指定。今回はPod metadata.nameにPodの名前をつける spec.containers以下にコンテナとそのイメージを書いていく。 上の場合だとnginxとechoという2つのコンテナを1つのPodとしてまとめている。 Pod関連のコマンド podを作成する際は $ kubectl apply -f myPod.yaml -fオプションの場合はyaml fileを指定、-kの場合はdirectoryを指定。 削除する場合は $ kubectl delete pod my-echo ログを表示したい場合は $ kubectl logs -f my-echo -c echo -cでコンテナを指定する。 -fはなくても実行できた。 とは打てばよい。 できたPodを確認するには $ kubectl get pods とうつ。 $ kubectl describe pod my-echo でPodの内容を詳細に表示。 PodはどこかのNodeに配置され、1つのPodが複数Nodeにまたがることはない。 ReplicaSet 上記のPodの場合は1つのPodしか作成できないが、実際には何個も作りたいことが多い その場合はReplicaSetを使う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_07/simple-replicaset.yaml myReplicaset.yaml apiVersion: apps/v1 kind: ReplicaSet # リソースの名前 metadata: name: echo # ReplicaSetに名前をつける labels: app: echo spec: # 以下Podの設定 replicas: 3 # いくつPodをつくるか selector: matchLabels: app: echo template: # template以下はPodリソースにおけるspec定義と同じ metadata: labels: app: echo spec: # 以下Podを構成するコンテナの設定(さっきと同じ) containers: - name: nginx image: gihyodocker/nginx:latest env: - name: BACKEND_HOST value: localhost:8080 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080 こんな感じで書く。 envの部分は環境変数を設定してる。 kubecltコマンドを使った作成の仕方はさっきと同様なので割愛。 Deployment ぱっと見ReplicaSetと似てる ReplicaSetの世代管理を行う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_08/simple-deployment.yaml myDeployment.yaml apiVersion: apps/v1 kind: Deployment # ここの名前が変わってる以外はほぼReplicasetと同じ metadata: name: echo labels: app: echo spec: replicas: 3 selector: matchLabels: app: echo template: # template以下はPodリソースにおけるspec定義と同じ metadata: labels: app: echo spec: containers: - name: nginx image: gihyodocker/nginx:latest env: - name: BACKEND_HOST value: localhost:8080 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:patched env: - name: HOGE value: fuga ports: - containerPort: 8080 こんな感じで書く。 Deploymentは名前の通りデプロイの単位として使われ、ReplicaSetがそのまま使われることはあまりない。 Deploymentはリビジョンを使ってReplicaSetの世代管理を行える。 そのため問題があった場合に一つ前のversionにロールバックしたりとかできる。 Podの数を増やしたり減らしたりとかもよしなにやってくれて便利。 Service Podを複数つくった場合、一つ一つのPodには別々のIPが割り当てられる Serviceを使えばそれらのアクセスポイントをひとつにまとめあげられる コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_09/simple-service.yaml myService.yaml apiVersion: v1 kind: Service # リソースの名前 metadata: name: echo # Serviceの名前 spec: selector: app: echo # appの名前。これに一致するapp, releaseを指定したPodと疎通できる release: summer ports: - name: http port: 80 # 80番ポートを公開 こんな感じで書く。 これでhttp://echo/にHTTPリクエストを通してPodに疎通できる。 厳密にはhttp://echo.{namespace}.svc.localだが、svc.localは省略可能。 namespaceはデフォルトだとdefaultになる。 Ingress Serviceはクラスター外には公開されない 外部に公開するにはIngressを使う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_10_1/simple-ingress.yaml myIngress.yaml apiVersion: extensions/v1beta1 kind: Ingress # リソースの名前 metadata: name: echo # Ingress名前 spec: rules: - host: ch05.gihyo.local # ここに外部からアクセスできる http: paths: - path: / backend: serviceName: echo # echoという名前のサービスの80番ポートを公開する servicePort: 80 まとめ 本の内容を自分なりにまとめた
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【メモ】Kubernetesのよく使うリソースまとめ【初心者】

概要 PodやらDeploymentやら、k8sのリソースは種類がいっぱいあってよくわからないのでまとめてみる 基本的に以下の書籍の内容をなぞる Docker/Kubernetes 実践コンテナ入門 github: https://github.com/yoskeoka/gihyo-docker-kuberbetes Node k8sクラスタが最も大きいリソース単位 クラスタの管理下にNodeがある AWSでいうEC2のインスタンス $ kubectl get nodes でクラスタ内nodeを確認 Namespace クラスタ内ではnamespaceごとに仮想的なクラスタを作成できる。 namespaceの一覧を見るには $ kubectl get namespace と打てばいい。 今後出てくるコマンドでnamespaceを指定したい場合は基本的に -n {namespame} のオプションをつければどうにかなる。 Pod 1個以上のコンテナの集合体 例 myPod.yaml apiVersion: v1 kind: Pod metadata: name: my-echo spec: containers: - name: nginx image: gihyodockernginx ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080 kindでリソースの種類を指定。今回はPod metadata.nameにPodの名前をつける spec.containers以下にコンテナとそのイメージを書いていく。 上の場合だとnginxとechoという2つのコンテナを1つのPodとしてまとめている。 Pod関連のコマンド podを作成する際は $ kubectl apply -f myPod.yaml -fオプションの場合はyaml fileを指定、-kの場合はdirectoryを指定。 削除する場合は $ kubectl delete pod my-echo ログを表示したい場合は $ kubectl logs -f my-echo -c echo -cでコンテナを指定する。 -fはなくても実行できた。 とは打てばよい。 できたPodを確認するには $ kubectl get pods とうつ。 $ kubectl describe pod my-echo でPodの内容を詳細に表示。 PodはどこかのNodeに配置され、1つのPodが複数Nodeにまたがることはない。 ReplicaSet 上記のPodの場合は1つのPodしか作成できないが、実際には何個も作りたいことが多い その場合はReplicaSetを使う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_07/simple-replicaset.yaml myReplicaset.yaml apiVersion: apps/v1 kind: ReplicaSet # リソースの名前 metadata: name: echo # ReplicaSetに名前をつける labels: app: echo spec: # 以下Podの設定 replicas: 3 # いくつPodをつくるか selector: matchLabels: app: echo template: # template以下はPodリソースにおけるspec定義と同じ metadata: labels: app: echo spec: # 以下Podを構成するコンテナの設定(さっきと同じ) containers: - name: nginx image: gihyodocker/nginx:latest env: - name: BACKEND_HOST value: localhost:8080 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080 こんな感じで書く。 envの部分は環境変数を設定してる。 kubecltコマンドを使った作成の仕方はさっきと同様なので割愛。 Deployment ぱっと見ReplicaSetと似てる ReplicaSetの世代管理を行う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_08/simple-deployment.yaml myDeployment.yaml apiVersion: apps/v1 kind: Deployment # ここの名前が変わってる以外はほぼReplicasetと同じ metadata: name: echo labels: app: echo spec: replicas: 3 selector: matchLabels: app: echo template: # template以下はPodリソースにおけるspec定義と同じ metadata: labels: app: echo spec: containers: - name: nginx image: gihyodocker/nginx:latest env: - name: BACKEND_HOST value: localhost:8080 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:patched env: - name: HOGE value: fuga ports: - containerPort: 8080 こんな感じで書く。 Deploymentは名前の通りデプロイの単位として使われ、ReplicaSetがそのまま使われることはあまりない。 Deploymentはリビジョンを使ってReplicaSetの世代管理を行える。 そのため問題があった場合に一つ前のversionにロールバックしたりとかできる。 Podの数を増やしたり減らしたりとかもよしなにやってくれて便利。 Service Podを複数つくった場合、一つ一つのPodには別々のIPが割り当てられる Serviceを使えばそれらのアクセスポイントをひとつにまとめあげられる コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_09/simple-service.yaml myService.yaml apiVersion: v1 kind: Service # リソースの名前 metadata: name: echo # Serviceの名前 spec: selector: app: echo # appの名前。これに一致するapp, releaseを指定したPodと疎通できる release: summer ports: - name: http port: 80 # 80番ポートを公開 こんな感じで書く。 これでhttp://echo/にHTTPリクエストを通してPodに疎通できる。 厳密にはhttp://echo.{namespace}.svc.localだが、svc.localは省略可能。 namespaceはデフォルトだとdefaultになる。 Ingress Serviceはクラスター外には公開されない 外部に公開するにはIngressを使う コード参考:https://github.com/yoskeoka/gihyo-docker-kuberbetes/blob/master/ch05/ch05_10_1/simple-ingress.yaml myIngress.yaml apiVersion: extensions/v1beta1 kind: Ingress # リソースの名前 metadata: name: echo # Ingress名前 spec: rules: - host: ch05.gihyo.local # ここに外部からアクセスできる http: paths: - path: / backend: serviceName: echo # echoという名前のサービスの80番ポートを公開する servicePort: 80 まとめ 本の内容を自分なりにまとめた
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

dockerとkubectl をWSL2で用意

以前、こちらの記事で書いた WSL (Wdinwos Subsystem Linux2) の続き。docker と kubectl をインストールしたのでメモ。 Docker ここに書いてあることをそのまま実行しただけ。 なのだが、読んでいると、docker repository の用意、GPGキーの登録、などがあり、実は今まで意識していなかったrepository のシステムも勉強せねばあかんという気にもなりました。 古いものは削除。私の環境では何もインストールされていない状態でした。 sudo apt-get remove docker docker-engine docker.io containerd runc repository を作る必要があるので、必要なライブラリをインストールして、Dockerのoffcial なGPGキーを登録する。だれがだれを認証するのか? $ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 素直に書かれている通り、hello-world を実行してみる。このimage はlocalにインストールされているらしい。 $ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ 最初、docker daemonが動いていない、と言われた。service をstart させたら事なきを得たことをメモ。 $ sudo docker run hello-world docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. $ sudo service docker stop * Docker already stopped - file /var/run/docker-ssd.pid not found. $ sudo service docker start * Starting Docker: docker kubectl 続いて、kubernetes を扱いたいので、kubectl をインストールした。 素直に従えばできた。バイナリとってくるだけ。 $ curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" $ chmod +x kubectl $ sudo mv ./kubectl /usr/local/bin/ $ kubectl version --client Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

dockerとkubectl とminikube をWSL2で用意

以前、こちらの記事で書いた WSL (Wdinwos Subsystem Linux2) の続き。docker と kubectl をインストールしたのでメモ。kubectl だけでは使えなくて、minikube も必要だと分かったのでそれも追加。^^;) Docker ここに書いてあることをそのまま実行しただけ。 なのだが、読んでいると、docker repository の用意、GPGキーの登録、などがあり、実は今まで意識していなかったrepository のシステムも勉強せねばあかんという気にもなりました。 古いものは削除。私の環境では何もインストールされていない状態でした。 sudo apt-get remove docker docker-engine docker.io containerd runc repository を作る必要があるので、必要なライブラリをインストールして、Dockerのoffcial なGPGキーを登録する。だれがだれを認証するのか? $ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 素直に書かれている通り、hello-world を実行してみる。このimage はlocalにインストールされているらしい。 $ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ 最初、docker daemonが動いていない、と言われた。service をstart させたら事なきを得たことをメモ。 $ sudo docker run hello-world docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. $ sudo service docker stop * Docker already stopped - file /var/run/docker-ssd.pid not found. $ sudo service docker start * Starting Docker: docker kubectl 続いて、kubernetes を扱いたいので、kubectl をインストールした。 素直に従えばできた。バイナリとってくるだけ。 $ curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" $ chmod +x kubectl $ sudo mv ./kubectl /usr/local/bin/ $ kubectl version --client Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"} で、これだけでは実は使い物にならない。何も設定されていない状態でした。 $ kubectl get pods The connection to the server localhost:8080 was refused - did you specify the right host or port? $ kubectl config view apiVersion: v1 clusters: null contexts: null current-context: "" kind: Config preferences: {} users: null 解説読んでいたら、 For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like Minikube to be installed first and then re-run the commands stated above. と書いてありました。 minikube を入れる。 minikube minikube を入れる。これも公式ページを参考にしました。 https://minikube.sigs.k8s.io/docs/start/ minikube インストール これもバイナリを入れるだけ。簡単。 $ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 $ sudo install minikube-linux-amd64 /usr/local/bin/minikube 動かしてみる いざ、minikube start でcluster? を動かすのだが、実は、driver としてdocker を指定しなければならなかった。でもエラーが出る。 $ minikube start --driver=docker ? minikube v1.19.0 on Ubuntu 20.04 ✨ Using the docker driver based on user configuration ? Exiting due to PROVIDER_DOCKER_NEWGRP: "docker version --format -" exit status 1: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: dial unix /var/run/docker.sock: connect: permission denied ? Suggestion: Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker' ? Documentation: https://docs.docker.com/engine/install/linux-postinstall/ docker コマンドが普通のユーザで使えない、という典型的な問題に遭遇。 親切にアドバイスを書かれてあるが、その通り。docker グループの登録させる。 (https://www7390uo.sakura.ne.jp/wordpress/archives/631) $ sudo usermod -aG docker $USER && newgrp docker その結果、無事に動いた。 $ minikube start --driver=docker ? minikube v1.19.0 on Ubuntu 20.04 ✨ Using the docker driver based on user configuration ? Starting control plane node minikube in cluster minikube ? Pulling base image ... ? Downloading Kubernetes v1.20.2 preload ... > gcr.io/k8s-minikube/kicbase...: 357.67 MiB / 357.67 MiB 100.00% 1.99 MiB > preloaded-images-k8s-v10-v1...: 491.71 MiB / 491.71 MiB 100.00% 2.55 MiB ? Creating docker container (CPUs=2, Memory=3100MB) ... ❗ This container is having trouble accessing https://k8s.gcr.io ? To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/ ? Preparing Kubernetes v1.20.2 on Docker 20.10.5 ... ▪ Generating certificates and keys ... ▪ Booting up control plane ... ▪ Configuring RBAC rules ... ? Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 ? Enabled addons: storage-provisioner, default-storageclass ? Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default 動いている感じがする。^^) $ kubectl cluster-info Kubernetes control plane is running at https://127.0.0.1:49154 KubeDNS is running at https://127.0.0.1:49154/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. $ kubectl get po -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-74ff55c5b-f2sb9 1/1 Running 0 6m29s kube-system etcd-minikube 1/1 Running 0 6m36s kube-system kube-apiserver-minikube 1/1 Running 0 6m36s kube-system kube-controller-manager-minikube 1/1 Running 0 6m36s kube-system kube-proxy-9zvzc 1/1 Running 0 6m29s kube-system kube-scheduler-minikube 1/1 Running 0 6m36s kube-system storage-provisioner 1/1 Running 0 6m43s deployとLoadBalancer の設定をチュートリアルに従って行う。既存のimage をdeploy して service でload balancer を設定してアクセス可能にするというもの。 kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4 kubectl expose deployment hello-minikube --type=NodePort --port=8080 ここLoadBalancer を expose しても EXTERNAL-IP が のままでしばらくはまりました。解決方法は、別ターミナルで minikube tunnel を実行しておく、でした。その結果、EXTERNAL-IPが与えられました。 $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube1 LoadBalancer 10.104.80.113 127.0.0.1 8080:31984/TCP 32m kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 77m きちんと読めてないけれどメモ。 https://kubernetes.io/docs/tutorials/hello-minikube/ https://minikube.sigs.k8s.io/docs/start/ 動いている minikube のAdd-On が見れました。 $ minikube addons list 最後にとりあえずcluster を delete しておいた。 $ minikube delete ? Deleting "minikube" in docker ... ? Deleting container "minikube" ... ? Removing /home/xtkd/.minikube/machines/minikube ... ? Removed all traces of the "minikube" cluster. まとめ 最低限、dockerとKubernetes がWSL2で動くようになった気がする。だが、kubernetesはminikube を導入したが、Google Cloud Platform で使っていたのとは違い、LoadBalancer が簡単には動かなかった。 もっとドキュメントをしっかり読まなければならない。 - https://minikube.sigs.k8s.io/docs/drivers/docker/ kubectl の設定。補完の設定方法とか書いてある。 https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ もう一度心を落ち着けて動かしてみたい。 https://kubernetes.io/ja/docs/tutorials/hello-minikube/ 今日は遅いので、もう寝ます。おじさんにはつらい。(2021.04.28 01:53)
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Machine-Learning-with-R-Cookbook-Second-Edition-master

Machine-Learning-with-R-Cookbook-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook Machine-Learning-with-R-Cookbook-Second-Edition-master Installing 'RPostgreSQL' ... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RPostgreSQL_0.6-2.tar.gz' Content type 'application/x-tar' length 582198 bytes (568 KB) ================================================== downloaded 568 KB * installing *source* package ‘RPostgreSQL’ ... ** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked ** using staged installation checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for pg_config... no configure: checking for PostgreSQL header files configure: Checking include /usr/include. configure: Checking include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include. configure: Checking include /usr/include/pgsql. configure: Checking include /usr/include/postgresql. configure: Checking include /usr/local/include. configure: Checking include /usr/local/include/pgsql. configure: Checking include /usr/local/include/postgresql. configure: Checking include /usr/local/pgsql/include. configure: Checking include /usr/local/postgresql/include. configure: Checking include /opt/include. configure: Checking include /opt/include/pgsql. configure: Checking include /opt/include/postgresql. configure: Checking include /opt/local/include. configure: Checking include /opt/local/include/postgresql. configure: Checking include /sw/include/postgresql. configure: Checking lib /usr/lib. configure: Checking lib /usr/lib/pgsql. configure: Checking lib /usr/lib/postgresql. configure: Checking lib /usr/local/lib. configure: Checking lib /usr/local/lib/pgsql. configure: Checking lib /usr/local/lib/postgresql. configure: Checking lib /usr/local/pgsql/lib. configure: Checking lib /usr/local/postgresql/lib. configure: Checking lib /opt/lib. configure: Checking lib /opt/lib/pgsql. configure: Checking lib /opt/lib/postgresql. configure: Checking lib /opt/local/lib. configure: Checking lib /opt/local/lib/postgresql. configure: Checking lib /sw/lib. configure: Using internal package libpq-fe.h checking for "src/libpq/libpq-fe.h"... yes configure: creating ./config.status config.status: creating src/Makevars ** libs gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RS-DBI.c -o RS-DBI.o gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RS-PQescape.c -o RS-PQescape.o In file included from RS-PQescape.c:7: RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory 23 | # include "libpq-fe.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [/usr/local/lib/R/etc/Makeconf:172: RS-PQescape.o] Error 1 ERROR: compilation failed for package ‘RPostgreSQL’ * removing ‘/usr/local/lib/R/site-library/RPostgreSQL’ The downloaded source packages are in ‘/tmp/RtmphvFqYA/downloaded_packages’ ✔ Package 'RPostgreSQL' successfully installed. Warning message: In utils::install.packages("RPostgreSQL", repos = "https://packagemanager.rstudio.com/all/__linux__/focal/latest") : installation of package ‘RPostgreSQL’ had non-zero exit status > class(x) [1] "numeric" ** Installing R Packages: 'Amelia', 'corrplot' [1/3] Installing RcppArmadillo... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RcppArmadillo_0.10.4.0.0.tar.gz' Content type 'binary/octet-stream' length 2250399 bytes (2.1 MB) ================================================== downloaded 2.1 MB * installing *binary* package ‘RcppArmadillo’ ... * DONE (RcppArmadillo) [2/3] Installing Amelia... The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Amelia_1.7.6.tar.gz' Content type 'binary/octet-stream' length 2452068 bytes (2.3 MB) ================================================== downloaded 2.3 MB [3/3] Installing corrplot... * installing *binary* package ‘Amelia’ ... * DONE (Amelia) The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/corrplot_0.84.tar.gz' Content type 'binary/octet-stream' length 5447375 bytes (5.2 MB) ================================================== downloaded 5.2 MB * installing *binary* package ‘corrplot’ ... * DONE (corrplot) The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ ✔ Packages successfully installed. > class(AirPassengers) [1] "ts" > data() > sample(1:10) [1] 10 2 4 5 3 8 7 1 9 6 > install.packages("car") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘backports’, ‘evaluate’, ‘highr’, ‘markdown’, ‘xfun’, ‘matrixStats’, ‘broom’, ‘knitr’, ‘SparseM’, ‘MatrixModels’, ‘conquer’, ‘sp’, ‘minqa’, ‘nloptr’, ‘statmod’, ‘carData’, ‘abind’, ‘pbkrtest’, ‘quantreg’, ‘maptools’, ‘lme4’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/backports_1.2.1.tar.gz' Content type 'binary/octet-stream' length 88661 bytes (86 KB) ================================================== downloaded 86 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/evaluate_0.14.tar.gz' Content type 'binary/octet-stream' length 74200 bytes (72 KB) ================================================== downloaded 72 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/highr_0.9.tar.gz' Content type 'binary/octet-stream' length 38825 bytes (37 KB) ================================================== downloaded 37 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/markdown_1.1.tar.gz' Content type 'binary/octet-stream' length 230388 bytes (224 KB) ================================================== downloaded 224 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xfun_0.22.tar.gz' Content type 'binary/octet-stream' length 310406 bytes (303 KB) ================================================== downloaded 303 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/matrixStats_0.58.0.tar.gz' Content type 'binary/octet-stream' length 2539233 bytes (2.4 MB) ================================================== downloaded 2.4 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/broom_0.7.6.tar.gz' Content type 'binary/octet-stream' length 1748118 bytes (1.7 MB) ================================================== downloaded 1.7 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/knitr_1.33.tar.gz' Content type 'binary/octet-stream' length 1401372 bytes (1.3 MB) ================================================== downloaded 1.3 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SparseM_1.81.tar.gz' Content type 'binary/octet-stream' length 1099766 bytes (1.0 MB) ================================================== downloaded 1.0 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/MatrixModels_0.5-0.tar.gz' Content type 'binary/octet-stream' length 448997 bytes (438 KB) ================================================== downloaded 438 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/conquer_1.0.2.tar.gz' Content type 'binary/octet-stream' length 1295108 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/sp_1.4-5.tar.gz' Content type 'binary/octet-stream' length 1855713 bytes (1.8 MB) ================================================== downloaded 1.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/minqa_1.2.4.tar.gz' Content type 'binary/octet-stream' length 479131 bytes (467 KB) ================================================== downloaded 467 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nloptr_1.2.2.2.tar.gz' Content type 'binary/octet-stream' length 1154405 bytes (1.1 MB) ================================================== downloaded 1.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/statmod_1.4.35.tar.gz' Content type 'binary/octet-stream' length 270979 bytes (264 KB) ================================================== downloaded 264 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/carData_3.0-4.tar.gz' Content type 'binary/octet-stream' length 1817389 bytes (1.7 MB) ================================================== downloaded 1.7 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/abind_1.4-5.tar.gz' Content type 'binary/octet-stream' length 60511 bytes (59 KB) ================================================== downloaded 59 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pbkrtest_0.5.1.tar.gz' Content type 'binary/octet-stream' length 351839 bytes (343 KB) ================================================== downloaded 343 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/quantreg_5.85.tar.gz' Content type 'binary/octet-stream' length 1641360 bytes (1.6 MB) ================================================== downloaded 1.6 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/maptools_1.1-1.tar.gz' Content type 'binary/octet-stream' length 2206488 bytes (2.1 MB) ================================================== downloaded 2.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lme4_1.1-26.tar.gz' Content type 'binary/octet-stream' length 9211344 bytes (8.8 MB) ================================================== downloaded 8.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/car_3.0-10.tar.gz' Content type 'binary/octet-stream' length 1555669 bytes (1.5 MB) ================================================== downloaded 1.5 MB * installing *binary* package ‘backports’ ... * DONE (backports) * installing *binary* package ‘evaluate’ ... * DONE (evaluate) * installing *binary* package ‘xfun’ ... * DONE (xfun) * installing *binary* package ‘matrixStats’ ... * DONE (matrixStats) * installing *binary* package ‘SparseM’ ... * DONE (SparseM) * installing *binary* package ‘MatrixModels’ ... * DONE (MatrixModels) * installing *binary* package ‘sp’ ... * DONE (sp) * installing *binary* package ‘minqa’ ... * DONE (minqa) * installing *binary* package ‘nloptr’ ... * DONE (nloptr) * installing *binary* package ‘statmod’ ... * DONE (statmod) * installing *binary* package ‘carData’ ... * DONE (carData) * installing *binary* package ‘abind’ ... * DONE (abind) * installing *binary* package ‘highr’ ... * DONE (highr) * installing *binary* package ‘markdown’ ... * DONE (markdown) * installing *binary* package ‘broom’ ... * DONE (broom) * installing *binary* package ‘conquer’ ... * DONE (conquer) * installing *binary* package ‘maptools’ ... * DONE (maptools) * installing *binary* package ‘lme4’ ... * DONE (lme4) * installing *binary* package ‘knitr’ ... * DONE (knitr) * installing *binary* package ‘quantreg’ ... * DONE (quantreg) * installing *binary* package ‘pbkrtest’ ... * DONE (pbkrtest) * installing *binary* package ‘car’ ... * DONE (car) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(car) Loading required package: carData Attaching package: ‘car’ The following object is masked from ‘package:arules’: recode > install.packages("survival") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/survival_3.2-10.tar.gz' Content type 'binary/octet-stream' length 6798373 bytes (6.5 MB) ================================================== downloaded 6.5 MB * installing *binary* package ‘survival’ ... * DONE (survival) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("C50") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/C50_0.1.3.1.tar.gz' Content type 'binary/octet-stream' length 604693 bytes (590 KB) ================================================== downloaded 590 KB * installing *binary* package ‘C50’ ... * DONE (C50) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(C50) > library(e1071) > model =svm(churn~., data = trainset, kernel="radial", cost=1, gamma = 1/ncol(trainset)) Error in eval(expr, p) : object 'trainset' not found > ind = cut(1:nrow(churnTrain), breaks=10, labels=F) Error in nrow(churnTrain) : object 'churnTrain' not found > install.packages("SuperLearner") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘caTools’, ‘gplots’, ‘ROCR’, ‘nnls’, ‘cvAUC’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caTools_1.18.2.tar.gz' Content type 'binary/octet-stream' length 247686 bytes (241 KB) ================================================== downloaded 241 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gplots_3.1.1.tar.gz' Content type 'binary/octet-stream' length 595163 bytes (581 KB) ================================================== downloaded 581 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ROCR_1.0-11.tar.gz' Content type 'binary/octet-stream' length 453521 bytes (442 KB) ================================================== downloaded 442 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nnls_1.4.tar.gz' Content type 'binary/octet-stream' length 40062 bytes (39 KB) ================================================== downloaded 39 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cvAUC_1.1.0.tar.gz' Content type 'binary/octet-stream' length 123484 bytes (120 KB) ================================================== downloaded 120 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SuperLearner_2.0-26.tar.gz' Content type 'binary/octet-stream' length 589292 bytes (575 KB) ================================================== downloaded 575 KB * installing *binary* package ‘caTools’ ... * DONE (caTools) * installing *binary* package ‘nnls’ ... * DONE (nnls) * installing *binary* package ‘gplots’ ... * DONE (gplots) * installing *binary* package ‘ROCR’ ... * DONE (ROCR) * installing *binary* package ‘cvAUC’ ... * DONE (cvAUC) * installing *binary* package ‘SuperLearner’ ... * DONE (SuperLearner) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("caret") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caret_6.0-86.tar.gz' Content type 'binary/octet-stream' length 6243866 bytes (6.0 MB) ================================================== downloaded 6.0 MB * installing *binary* package ‘caret’ ... * DONE (caret) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("glmnet") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘shape’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/shape_1.4.5.tar.gz' Content type 'binary/octet-stream' length 784267 bytes (765 KB) ================================================== downloaded 765 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/glmnet_4.1-1.tar.gz' Content type 'binary/octet-stream' length 2000378 bytes (1.9 MB) ================================================== downloaded 1.9 MB * installing *binary* package ‘shape’ ... * DONE (shape) * installing *binary* package ‘glmnet’ ... * DONE (glmnet) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("xgboost") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xgboost_1.4.1.1.tar.gz' Content type 'binary/octet-stream' length 16247624 bytes (15.5 MB) ================================================== downloaded 15.5 MB * installing *binary* package ‘xgboost’ ... * DONE (xgboost) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("randomForest") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/randomForest_4.6-14.tar.gz' Content type 'binary/octet-stream' length 257439 bytes (251 KB) ================================================== downloaded 251 KB * installing *binary* package ‘randomForest’ ... * DONE (randomForest) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(SuperLearner) Loading required package: nnls Super Learner Version: 2.0-26 Package created on 2019-10-27 > data(Boston, package="MASS") > training = sample(nrow(Boston), 100) > X = Boston[training, ] > X_Hold = Boston[-training, ] > Y = Boston$medv[training, ] Error in Boston$medv[training, ] : incorrect number of dimensions > Y_Hold = Boston$medv[-training, ] Error in Boston$medv[-training, ] : incorrect number of dimensions > customer= read.csv('customer.csv', header=TRUE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'customer.csv': No such file or directory > head(customer) Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'head': object 'customer' not found > > library(arules) Loading required package: Matrix Attaching package: ‘arules’ The following objects are masked from ‘package:base’: abbreviate, write > tr_list = list(c("Apple", "Bread", "Cake"), + c("Apple", "Bread", "Milk"), + c("Bread", "Cake", "Milk")) > names(tr_list) = paste("Tr",c(1:3), sep = "") > trans = as(tr_list, "transactions") > trans transactions in sparse format with 3 transactions (rows) and 4 items (columns) > tr_matrix = matrix( + c(1,1,1,0, + 1,1,0,1, + 0,1,1,1), ncol = 4) > dimnames(tr_matrix) = list( + paste("Tr",c(1:3), sep = ""), + c("Apple","Bread","Cake", "Milk") + ) > trans2 = as(tr_matrix, "transactions") > trans2 transactions in sparse format with 3 transactions (rows) and 4 items (columns) > Tr_df = data.frame( + TrID= as.factor(c(1,2,1,1,2,3,2,3,2,3)), + Item = as.factor(c("Apple","Milk","Cake","Bread", + "Cake","Milk","Apple","Cake","Bread","Bread"))) > trans3 = as(split(Tr_df[,"Item"], Tr_df[,"TrID"]), "trans-actions") Error in as(split(Tr_df[, "Item"], Tr_df[, "TrID"]), "trans-actions") : no method or default for coercing “list” to “trans-actions” > trans3 Error: object 'trans3' not found
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Machine-Learning-with-R-Cookbook-Second-Edition-master:dockerで機械学習(78) with R (8)

Machine-Learning-with-R-Cookbook-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook Machine-Learning-with-R-Cookbook-Second-Edition-master Installing 'RPostgreSQL' ... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RPostgreSQL_0.6-2.tar.gz' Content type 'application/x-tar' length 582198 bytes (568 KB) ================================================== downloaded 568 KB * installing *source* package ‘RPostgreSQL’ ... ** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked ** using staged installation checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for pg_config... no configure: checking for PostgreSQL header files configure: Checking include /usr/include. configure: Checking include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include. configure: Checking include /usr/include/pgsql. configure: Checking include /usr/include/postgresql. configure: Checking include /usr/local/include. configure: Checking include /usr/local/include/pgsql. configure: Checking include /usr/local/include/postgresql. configure: Checking include /usr/local/pgsql/include. configure: Checking include /usr/local/postgresql/include. configure: Checking include /opt/include. configure: Checking include /opt/include/pgsql. configure: Checking include /opt/include/postgresql. configure: Checking include /opt/local/include. configure: Checking include /opt/local/include/postgresql. configure: Checking include /sw/include/postgresql. configure: Checking lib /usr/lib. configure: Checking lib /usr/lib/pgsql. configure: Checking lib /usr/lib/postgresql. configure: Checking lib /usr/local/lib. configure: Checking lib /usr/local/lib/pgsql. configure: Checking lib /usr/local/lib/postgresql. configure: Checking lib /usr/local/pgsql/lib. configure: Checking lib /usr/local/postgresql/lib. configure: Checking lib /opt/lib. configure: Checking lib /opt/lib/pgsql. configure: Checking lib /opt/lib/postgresql. configure: Checking lib /opt/local/lib. configure: Checking lib /opt/local/lib/postgresql. configure: Checking lib /sw/lib. configure: Using internal package libpq-fe.h checking for "src/libpq/libpq-fe.h"... yes configure: creating ./config.status config.status: creating src/Makevars ** libs gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RS-DBI.c -o RS-DBI.o gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RS-PQescape.c -o RS-PQescape.o In file included from RS-PQescape.c:7: RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory 23 | # include "libpq-fe.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [/usr/local/lib/R/etc/Makeconf:172: RS-PQescape.o] Error 1 ERROR: compilation failed for package ‘RPostgreSQL’ * removing ‘/usr/local/lib/R/site-library/RPostgreSQL’ The downloaded source packages are in ‘/tmp/RtmphvFqYA/downloaded_packages’ ✔ Package 'RPostgreSQL' successfully installed. Warning message: In utils::install.packages("RPostgreSQL", repos = "https://packagemanager.rstudio.com/all/__linux__/focal/latest") : installation of package ‘RPostgreSQL’ had non-zero exit status > class(x) [1] "numeric" ** Installing R Packages: 'Amelia', 'corrplot' [1/3] Installing RcppArmadillo... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RcppArmadillo_0.10.4.0.0.tar.gz' Content type 'binary/octet-stream' length 2250399 bytes (2.1 MB) ================================================== downloaded 2.1 MB * installing *binary* package ‘RcppArmadillo’ ... * DONE (RcppArmadillo) [2/3] Installing Amelia... The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Amelia_1.7.6.tar.gz' Content type 'binary/octet-stream' length 2452068 bytes (2.3 MB) ================================================== downloaded 2.3 MB [3/3] Installing corrplot... * installing *binary* package ‘Amelia’ ... * DONE (Amelia) The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/corrplot_0.84.tar.gz' Content type 'binary/octet-stream' length 5447375 bytes (5.2 MB) ================================================== downloaded 5.2 MB * installing *binary* package ‘corrplot’ ... * DONE (corrplot) The downloaded source packages are in ‘/tmp/RtmpMDZZhf/downloaded_packages’ ✔ Packages successfully installed. > class(AirPassengers) [1] "ts" > data() > sample(1:10) [1] 10 2 4 5 3 8 7 1 9 6 > install.packages("car") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘backports’, ‘evaluate’, ‘highr’, ‘markdown’, ‘xfun’, ‘matrixStats’, ‘broom’, ‘knitr’, ‘SparseM’, ‘MatrixModels’, ‘conquer’, ‘sp’, ‘minqa’, ‘nloptr’, ‘statmod’, ‘carData’, ‘abind’, ‘pbkrtest’, ‘quantreg’, ‘maptools’, ‘lme4’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/backports_1.2.1.tar.gz' Content type 'binary/octet-stream' length 88661 bytes (86 KB) ================================================== downloaded 86 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/evaluate_0.14.tar.gz' Content type 'binary/octet-stream' length 74200 bytes (72 KB) ================================================== downloaded 72 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/highr_0.9.tar.gz' Content type 'binary/octet-stream' length 38825 bytes (37 KB) ================================================== downloaded 37 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/markdown_1.1.tar.gz' Content type 'binary/octet-stream' length 230388 bytes (224 KB) ================================================== downloaded 224 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xfun_0.22.tar.gz' Content type 'binary/octet-stream' length 310406 bytes (303 KB) ================================================== downloaded 303 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/matrixStats_0.58.0.tar.gz' Content type 'binary/octet-stream' length 2539233 bytes (2.4 MB) ================================================== downloaded 2.4 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/broom_0.7.6.tar.gz' Content type 'binary/octet-stream' length 1748118 bytes (1.7 MB) ================================================== downloaded 1.7 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/knitr_1.33.tar.gz' Content type 'binary/octet-stream' length 1401372 bytes (1.3 MB) ================================================== downloaded 1.3 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SparseM_1.81.tar.gz' Content type 'binary/octet-stream' length 1099766 bytes (1.0 MB) ================================================== downloaded 1.0 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/MatrixModels_0.5-0.tar.gz' Content type 'binary/octet-stream' length 448997 bytes (438 KB) ================================================== downloaded 438 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/conquer_1.0.2.tar.gz' Content type 'binary/octet-stream' length 1295108 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/sp_1.4-5.tar.gz' Content type 'binary/octet-stream' length 1855713 bytes (1.8 MB) ================================================== downloaded 1.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/minqa_1.2.4.tar.gz' Content type 'binary/octet-stream' length 479131 bytes (467 KB) ================================================== downloaded 467 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nloptr_1.2.2.2.tar.gz' Content type 'binary/octet-stream' length 1154405 bytes (1.1 MB) ================================================== downloaded 1.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/statmod_1.4.35.tar.gz' Content type 'binary/octet-stream' length 270979 bytes (264 KB) ================================================== downloaded 264 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/carData_3.0-4.tar.gz' Content type 'binary/octet-stream' length 1817389 bytes (1.7 MB) ================================================== downloaded 1.7 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/abind_1.4-5.tar.gz' Content type 'binary/octet-stream' length 60511 bytes (59 KB) ================================================== downloaded 59 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pbkrtest_0.5.1.tar.gz' Content type 'binary/octet-stream' length 351839 bytes (343 KB) ================================================== downloaded 343 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/quantreg_5.85.tar.gz' Content type 'binary/octet-stream' length 1641360 bytes (1.6 MB) ================================================== downloaded 1.6 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/maptools_1.1-1.tar.gz' Content type 'binary/octet-stream' length 2206488 bytes (2.1 MB) ================================================== downloaded 2.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lme4_1.1-26.tar.gz' Content type 'binary/octet-stream' length 9211344 bytes (8.8 MB) ================================================== downloaded 8.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/car_3.0-10.tar.gz' Content type 'binary/octet-stream' length 1555669 bytes (1.5 MB) ================================================== downloaded 1.5 MB * installing *binary* package ‘backports’ ... * DONE (backports) * installing *binary* package ‘evaluate’ ... * DONE (evaluate) * installing *binary* package ‘xfun’ ... * DONE (xfun) * installing *binary* package ‘matrixStats’ ... * DONE (matrixStats) * installing *binary* package ‘SparseM’ ... * DONE (SparseM) * installing *binary* package ‘MatrixModels’ ... * DONE (MatrixModels) * installing *binary* package ‘sp’ ... * DONE (sp) * installing *binary* package ‘minqa’ ... * DONE (minqa) * installing *binary* package ‘nloptr’ ... * DONE (nloptr) * installing *binary* package ‘statmod’ ... * DONE (statmod) * installing *binary* package ‘carData’ ... * DONE (carData) * installing *binary* package ‘abind’ ... * DONE (abind) * installing *binary* package ‘highr’ ... * DONE (highr) * installing *binary* package ‘markdown’ ... * DONE (markdown) * installing *binary* package ‘broom’ ... * DONE (broom) * installing *binary* package ‘conquer’ ... * DONE (conquer) * installing *binary* package ‘maptools’ ... * DONE (maptools) * installing *binary* package ‘lme4’ ... * DONE (lme4) * installing *binary* package ‘knitr’ ... * DONE (knitr) * installing *binary* package ‘quantreg’ ... * DONE (quantreg) * installing *binary* package ‘pbkrtest’ ... * DONE (pbkrtest) * installing *binary* package ‘car’ ... * DONE (car) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(car) Loading required package: carData Attaching package: ‘car’ The following object is masked from ‘package:arules’: recode > install.packages("survival") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/survival_3.2-10.tar.gz' Content type 'binary/octet-stream' length 6798373 bytes (6.5 MB) ================================================== downloaded 6.5 MB * installing *binary* package ‘survival’ ... * DONE (survival) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("C50") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/C50_0.1.3.1.tar.gz' Content type 'binary/octet-stream' length 604693 bytes (590 KB) ================================================== downloaded 590 KB * installing *binary* package ‘C50’ ... * DONE (C50) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(C50) > library(e1071) > model =svm(churn~., data = trainset, kernel="radial", cost=1, gamma = 1/ncol(trainset)) Error in eval(expr, p) : object 'trainset' not found > ind = cut(1:nrow(churnTrain), breaks=10, labels=F) Error in nrow(churnTrain) : object 'churnTrain' not found > install.packages("SuperLearner") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘caTools’, ‘gplots’, ‘ROCR’, ‘nnls’, ‘cvAUC’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caTools_1.18.2.tar.gz' Content type 'binary/octet-stream' length 247686 bytes (241 KB) ================================================== downloaded 241 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gplots_3.1.1.tar.gz' Content type 'binary/octet-stream' length 595163 bytes (581 KB) ================================================== downloaded 581 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ROCR_1.0-11.tar.gz' Content type 'binary/octet-stream' length 453521 bytes (442 KB) ================================================== downloaded 442 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nnls_1.4.tar.gz' Content type 'binary/octet-stream' length 40062 bytes (39 KB) ================================================== downloaded 39 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cvAUC_1.1.0.tar.gz' Content type 'binary/octet-stream' length 123484 bytes (120 KB) ================================================== downloaded 120 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SuperLearner_2.0-26.tar.gz' Content type 'binary/octet-stream' length 589292 bytes (575 KB) ================================================== downloaded 575 KB * installing *binary* package ‘caTools’ ... * DONE (caTools) * installing *binary* package ‘nnls’ ... * DONE (nnls) * installing *binary* package ‘gplots’ ... * DONE (gplots) * installing *binary* package ‘ROCR’ ... * DONE (ROCR) * installing *binary* package ‘cvAUC’ ... * DONE (cvAUC) * installing *binary* package ‘SuperLearner’ ... * DONE (SuperLearner) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("caret") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caret_6.0-86.tar.gz' Content type 'binary/octet-stream' length 6243866 bytes (6.0 MB) ================================================== downloaded 6.0 MB * installing *binary* package ‘caret’ ... * DONE (caret) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("glmnet") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘shape’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/shape_1.4.5.tar.gz' Content type 'binary/octet-stream' length 784267 bytes (765 KB) ================================================== downloaded 765 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/glmnet_4.1-1.tar.gz' Content type 'binary/octet-stream' length 2000378 bytes (1.9 MB) ================================================== downloaded 1.9 MB * installing *binary* package ‘shape’ ... * DONE (shape) * installing *binary* package ‘glmnet’ ... * DONE (glmnet) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("xgboost") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xgboost_1.4.1.1.tar.gz' Content type 'binary/octet-stream' length 16247624 bytes (15.5 MB) ================================================== downloaded 15.5 MB * installing *binary* package ‘xgboost’ ... * DONE (xgboost) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > install.packages("randomForest") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/randomForest_4.6-14.tar.gz' Content type 'binary/octet-stream' length 257439 bytes (251 KB) ================================================== downloaded 251 KB * installing *binary* package ‘randomForest’ ... * DONE (randomForest) The downloaded source packages are in ‘/tmp/RtmpgixwWH/downloaded_packages’ > library(SuperLearner) Loading required package: nnls Super Learner Version: 2.0-26 Package created on 2019-10-27 > data(Boston, package="MASS") > training = sample(nrow(Boston), 100) > X = Boston[training, ] > X_Hold = Boston[-training, ] > Y = Boston$medv[training, ] Error in Boston$medv[training, ] : incorrect number of dimensions > Y_Hold = Boston$medv[-training, ] Error in Boston$medv[-training, ] : incorrect number of dimensions > customer= read.csv('customer.csv', header=TRUE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'customer.csv': No such file or directory > head(customer) Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'head': object 'customer' not found > > library(arules) Loading required package: Matrix Attaching package: ‘arules’ The following objects are masked from ‘package:base’: abbreviate, write > tr_list = list(c("Apple", "Bread", "Cake"), + c("Apple", "Bread", "Milk"), + c("Bread", "Cake", "Milk")) > names(tr_list) = paste("Tr",c(1:3), sep = "") > trans = as(tr_list, "transactions") > trans transactions in sparse format with 3 transactions (rows) and 4 items (columns) > tr_matrix = matrix( + c(1,1,1,0, + 1,1,0,1, + 0,1,1,1), ncol = 4) > dimnames(tr_matrix) = list( + paste("Tr",c(1:3), sep = ""), + c("Apple","Bread","Cake", "Milk") + ) > trans2 = as(tr_matrix, "transactions") > trans2 transactions in sparse format with 3 transactions (rows) and 4 items (columns) > Tr_df = data.frame( + TrID= as.factor(c(1,2,1,1,2,3,2,3,2,3)), + Item = as.factor(c("Apple","Milk","Cake","Bread", + "Cake","Milk","Apple","Cake","Bread","Bread"))) > trans3 = as(split(Tr_df[,"Item"], Tr_df[,"TrID"]), "trans-actions") Error in as(split(Tr_df[, "Item"], Tr_df[, "TrID"]), "trans-actions") : no method or default for coercing “list” to “trans-actions” > trans3 Error: object 'trans3' not found
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Raspberry Pi zero WHでyoutubeライブ配信

問題 ffmpegのパラメータ調べたり面倒くさそう。 解決策 alexellis2/streamingを使う。 Live stream to YouTube with your Raspberry Pi and Docker YouTube live-streaming made easy まずdocker、docker-composeを入れる $ curl -sSL https://get.docker.com | sh $ sudo usermod -aG docker <username> # piとかに変える これでdockerコマンドがsudo無しで出来る $ sudo apt update $ sudo apt install -y python3-pip libffi-dev $ sudo pip3 install docker-compose # python経由で入れるとスルッと入る docker-compose.ymlとentry.sh docker-compose.yml version: "3" services: live: image: alexellis2/streaming:07-05-2018 privileged: true volumes: - ./entry.sh:/root/entry.sh entrypoint: ["/root/entry.sh", "********自分のストリームキー********"] 元々のentry.shだとどうしてもfpsが20を下回り、youtube側でバッファの遅延が起きていたので、動画サイズを落として、ビットレートも落とした。 entry.sh #!/bin/bash echo Live-stream secret: $1 # https://support.google.com/youtube/answer/2853702#zippy=%2Cp%2Cp-fps raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 3000000 -g 40 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i pipe:0 -c:v copy -c:a aac -ab 128k -g 40 -strict experimental -f flv -r 30 rtmp://a.rtmp.youtube.com/live2/$1 オリジナルのentry.sh #!/bin/bash echo Live-stream secret: $1 raspivid -o - -t 0 -w 1920 -h 1080 -fps 40 -b 8000000 -g 40 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i pipe:0 -c:v copy -c:a aac -ab 128k -g 40 -strict experimental -f flv -r 30 rtmp://a.rtmp.youtube.com/live2/$1 docker-compose.ymlとentry.shを同じ場所に置いて $ docker-compose run --rm live とすると良いと思う。 -w 1280 -h 720 -fps 30 -b 3000000だとfps=25は出てた。(室温23℃前後、CPU温度55℃前後)
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【Docker】Windowsでdockerが起動できないときの対処法。wsl : The term 'wsl' is not recognizedエラー解決法

Docker desktop for windowsをインストールして起動しようとしたところエラーで止まってしまう。 また、microsoftの公式手順に従ってWSL(windows用のサブlinux os)を導入しようとするとエラーが発生した場合の対処法。 エラー例 wsl --set-default-version 2 wsl : The term 'wsl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 wslコマンドは認識できないというエラー 目次 WSLとは? 管理者権限でターミナル(PowerShell)を起動する WSLオプション機能を有効にする WSL2をダウンロードする WSL2を規定バージョンに設定する Docker desktopをリスタート WSLとは? Windows Subsystem for Linuxの略でWindows10でLinuxを使う仕組みのこと。 windows上でLinuxを起動することができる。 WSLを使わない場合はHyper-vというLinuxの仮想環境上でDockerを起動する必要があった。 起動手順 1. 管理者権限でターミナル(PowerShell)を起動する アプリを右クリックして「管理者として実行」を選択する。 2. WSLオプション機能を有効にする 立ち上げたターミナルで以下を実行。 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 3. WSL2をダウンロードする インストールが完了したら、ダブルクリックして展開する。 microsoftのHPで確認できます 4. WSL2を規定バージョンに設定する 以下コマンドを実行する。PowerShellで実行と書いてあるが実行するとエラーが発生する。 git bashなど他のアプリケーションを使うことで実行できる。 wsl --set-default-version 2 以上でWSLのインストールは完了。 5. Docker desktopをリスタート Dockerアイコンを右クリックし、下から2番めの「Restart Docker」をクリック。 Dockerアイコンが赤色から白色になれば起動成功。 dockerの実行 dockerやdocker-composeコマンドが実行できる。 PS > docker-compose up Docker Compose is now in the Docker CLI, try `docker compose up` Creating network "vscode_default" with the default driver Pulling db (mysql:5.6)...
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

はじめてのodooカスタムモジュール - DockerとVisual Studio Codeを使った開発環境

DockerとVisual Studio Codeを使って、odooの開発環境を構築し、odooカスタムモジュールを作成・インストールします。 参考ページ: Docker Official Images Odoo (formerly known as OpenERP) is a suite of open-source business apps. Creating your first Odoo module using Docker and Visual Studio Code Russell Briggs Jun 29, 2020 はじめに 本記事では、次の3つについて、説明しています。 odooのDocker開発環境を作成し、実行します。 Visual Studio Code(以下、VSCode)をインストールし、Dockerにアクセスするための構成を設定します。 開発環境でodooカスタムモジュールを新規に作成し、odooデータベースにインストールします。 前提条件 この記事の内容を検証するには、次のものが必要です。 Windows10 Home (64bit版, バージョン 20H2) Git for Windowsのインストール (git bashを使うため) Docker Desktopのインストール Docker Desktopのインストール後、「Linux カーネル更新プログラム」のインストールが必要な場合があります。 PostgreSQLデータベースサーバーへのアクセス環境 git bashで次のコマンドを実行します。 odoodb.sh docker run -d \ -e POSTGRES_USER=odoo \ -e POSTGRES_PASSWORD=odoo \ -e POSTGRES_DB=postgres \ -v postgres11-data:/var/lib/postgresql/data \ -p 5432:5432 \ --name db postgres:11 素のodooデータベースを備えたDockerで実行されているodooのコピー これにはjunari/odoo Dockerイメージを使用することをお勧めします。これについては、次のステップ1で説明します。:) ステップ1:Docker開発環境を起動します junari/odoo Dockerイメージを使用する場合は、次のコマンドを使用してodoo開発環境を起動できます(作業を楽にするために、シェルスクリプトファイルとして保存しておくことをお勧めします!) odoojunari.sh docker run --rm -it \ --name=junari-odoo-dev \ -v junari-odoo-data:/opt/odoo/data \ -v junari-odoo-vscode:/opt/odoo/.vscode \ -v junari-odoo-custom-addons:/opt/odoo/custom_addons \ -v junari-odoo-home:/home/odoo \ -p 8069:8069 \ --env-file=odoo.env \ junari/odoo \ bash odoo.envファイルを参照していますので、実行前にカレントディレクトリに次のファイルを作成してください。 odoo.env DB_HOST=host.docker.internal DB_PORT=5432 DB_USER=odoo DB_PASSWORD=odoo ODOO_EXTRA_ARGS= --db-filter=^%d$ ファイル追加後、再実行するとエラーが出ますので、exec winpty bashを事前に実行してから、再実行してください。 exec winpty bash このコマンドが何をしているのかを、確認していきましょう。 junari-odoo-devと名付けた新しいjunari/odooコンテナを起動します。 次のようなDocker「ボリューム」(ミニ仮想ハードディスクのようなもの)に接続します。 junari-odoo-dataボリューム アップロードやセッションに関するodooファイルを保存します junari-odoo-vscodeボリューム Visual Studio Codeのワークスペースファイルを保持します junari-odoo-custom-addonsボリューム ここで、新しいodooカスタムモジュールを開発します junari-odoo-homeボリューム odooユーザー(開発ユーザー)のホームディレクトリを指定します。 VS Codeはここにいくつかのファイルを保存します。また、コードをGitHubにアップロードする場合は、SSHキーをこのフォルダーに配置する必要があります。 コンテナが実行されると、「bash」コマンドプロンプトが表示されます。 ステップ2:DockerコンテナーにアクセスするようにVSCodeを構成する VSCodeをまだお持ちでない場合は、こちらからダウンロードしてください。 VSCodeには、コンテナ(さらには、仮想マシンやWSLも)内にいるかのように開発できる優れた「リモート開発」機能があります。これは、VS Code Serverユーティリティをコンテナ内のホームディレクトリにアップロードすることで機能しています。このユーティリティを使用して、VSCodeユーザーインターフェイスからコンテナ内で直接コードを実行できます。うまく出来ていますよね。 DockerコンテナーでVSCodeリモート開発を使用するには、最初に「Remote-Containers」拡張機能をインストールしてください。「Extentions」ツールバーボタンをクリックし、「remote」をキーワードとして拡張機能を検索し、インストールします。 これをインストールしたら、「Remote Explorer」ツールバーボタンをクリックします odooコンテナが実行されている場合は、「Others Containers」リストに表示されます(「Others Containers」とは、まだVSCodeで開発用に使用されていないコンテナです)。 開発用のコンテナを開くには、名前の右側にある小さな四角をクリックすると(Attach to Container)、新しいVSCodeウィンドウが起動します。すると、VSCodeによって、サーバーユーティリティがコンテナのodooホームフォルダーに自動的にインストールされ、「Welcome」画面が表示されます。 ソースコードにアクセスできるようにするには、VS Codeの左上にある「Explorer」ツールバーボタンをクリックして、「Open Folder」ボタンをクリックします。 すると、「Open Folder」ダイアログがポップアップ表示されます。 /home/odoo を /opt/odoo に変更し、OKボタンをクリックすると、odooコードのルートフォルダーが開かれます。 これで、準備が整いました。 ステップ3:odooモジュールを新規に作成する このステップでは、「空の」odooモジュールを作成し、odooデータベースにインストールする準備をします。 custom_addonsフォルダを開き、その中に新規にcontact_widgetsフォルダを追加作成します。 さらにそのフォルダの中に、2つの空のファイル、__manifest__.pyと__init__.pyを作成します。 __manifest__.pyファイルを開き、次のとおりに、編集し、保存します。 __manifest__.py { 'name': 'Contact Widgets Module', 'version': '13.0.0', 'summary': 'Test Module', 'author': 'My Company Ltd', 'website': 'https://www.mycompany.com', 'depends': [ 'contact', ], 'data': [ ], 'installable': True, 'application': True, 'auto_install': False, } はじめてのodooモジュールを作成できました。さらに進めていきましょう。 ステップ4:VSCode Python拡張機能をインストールし、odooを起動します。 新しいodoo開発コンテナを初めて使用するときは、そのコンテナ中にPython拡張機能をインストールする必要があります。これを行うには、コンテナーに接続されているVSCodeウィンドウ内から、Extentionsツールバーボタンを押し、Pythonをキーワードに検索して、「Install in Container junari/odoo (/junari-odoo-dev)」ボタンを押下します。「ウィンドウのリロード」を求められたら、それを実行してください。 次に行わなければいけないことは、正しいPythonインタープリターを選択することです。 Pythonファイルをクリックすると、これを行うように求められますが、そうでない場合は、VSCodeステータスバーを確認して、Python通知をクリックしてください。 ※ 執筆現在、Python 3.6.9 64bitを選択しました。 次に、VSCodeにodooの起動方法を指示する「Launch Configuration」を作成する必要があります。 これを行うには、「Run and Debug」ツールバーボタンをクリックし、「create a launch.json file」リンクをクリックして、「Python」、「Python File」の順に選択します。これにより、ワークスペースの.vscodeフォルダーに新しいlaunch.jsonファイルが作成されます。 launch.jsonの内容を次のように置き換え、保存します。 launch.json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information visit: // https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Odoo", "type": "python", "request": "launch", "cwd": "${workspaceRoot}", "program": "${workspaceRoot}/odoo/odoo-bin", "args": [ "--db_host=${env:DB_HOST}", "--db_port=${env:DB_PORT}", "--db_user=${env:DB_USER}", "--db_password=${env:DB_PASSWORD}", "--database=odoo13", "--limit-time-real=100000" ], "console": "integratedTerminal" } ] } これで、VSCodeの「実行」領域に「Odoo」オプションが表示されます。 緑色の「Start Debugging」ボタンを押すと、odooが起動します。 ステップ5:カスタムモジュールをインストールします! これですべてが実行されます。ブラウザで http://localhost:8069/ を起動し、odooデータベースにログインします(admin/admin)。 Appsモジュールを見ると、新しいウィジェットアプリが表示されていないことがわかるでしょう。これは、odooに新しいモジュールと更新されたモジュールをスキャンさせる必要があるためです。 そのスキャンを行うには、開発者モードを有効にする必要があります。これを行うには次の2つの方法があります。 【通常の方法】Setting -> General Settings に移動し、Activate the developer modeリンクをクリックします。 ※初期状態ではGeneral Settingsがありません。例えば「Discuss」などのアプリをインストールすると表示されます。 【簡単な方法】?debug=1をブラウザのアドレスバーに追加してEnterキーを押すだけです。 http://localhost:8069/?debug=1 これで開発者モードが有効になりました。Odooの「Apps」領域に、「Update Apps List」メニュー項目が表示されます。これを押下すると表示される画面の「Update」ボタンを押下し、利用可能なアプリのリストを更新します。 すべてがうまくいっていれば、検索するとピッカピカの新しいモジュールが表示されるはずです。 「Install」ボタンを押してインストールし、成功をかみしめてください。 おっとー、「contact」モジュールが見つからないですって!? __manifest__.py { 'name': 'Contact Widgets Module', : : 'depends': [ 'contacts', ], : : } おわりに 本記事では、DockerとVSCodeを使った開発環境を構築し、odooカスタムモジュールを作成し、インストールしました。 Git、Docker、PostgresSQL実行環境を準備しました。 junari/odoo Dockerイメージを使用して、dockerコンテナを起動しました。 VSCodeをインストールし、dockerコンテナにアクセスできるようにしました。 odooカスタムモジュールを新規に作成しましたq。 Python拡張機能をつかって、odooを起動しました。 odooカスタムモジュールをインストールしました。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Dockerとvagrantを一緒に使ってVagrant upができなくなった件について

はじめに Dockerを普段は利用しているのですが、昔利用していたVagrantを利用したい場面が出たので、いつも通りvagrant upしたらエラーが発生したので、その時の対処方法を調べたのでまとめます。 問題 vagrant upするとこのようなエラーがでました。 Stderr: VBoxManage.exe: error: VMMR0_DO_NEM_INIT_VM failed: VERR_NEM_MISSING_KERNEL_API_2 (VERR_NEM_MISSING_KERNEL_API_2). Dockerとvagrantは一緒に使ってしまうとエラーの原因になるようです。 解決方法 ① windowsの検索画面からWindowsの機能の有効かまたは無効化 をクリック ・Hyper-T ・Containers のチェックを外す ② コマンドプロンプトを起動 bcdedit # コマンドを実行 bcdedit /set hypervisorlaunchtype off # コマンドを実行 おわりに これを行うと次はDockerのほうでエラーがでるので設定を戻さなければなりませんでした。 VagrantとDockerは共存ができません。 二つ利用したい場合は、Vagrantの上にDockerを載せて二つを利用するのが良いかもしれません。 ※この投稿は以前使っていたアカウントにて2020年6月3日に投稿されたものです。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む