前提
タイトルの通り、xserverでpandas、numpyを使用したいのですが、[Internal Server Error]が表示されてしまいます。
https://dattesar.com/xserver-pip-flask/
上記サイト等をもとにターミナルからxserverにSSH接続し、xserver上にanacondaをインストールしてpython環境を構築しました。
pipコマンド(試しにcondaコマンドでも)でnumpy, pandasをインストール済みです。
また、簡単なhtmlファイル等をhttp://[サーバーID].xsrv.jp/testapp/test (testappは仮想環境名, testは実行するページ(関数)名)で表示させることはできています。
上記サイトやその他「xserverにpython(flask)環境を構築する」等のサイトを見ても、numpyやpandasはダウンロードしているものの、実際にそれらを使用して実行している例が見つからなかったため、こちらで質問させていただきました。
実現したいこと
・正常にpandas, numpyが公開サイト上で機能していることを確かめたい。
・pandasのpd.read_csv('~.csv')を使用して、csvファイルを読み込みたい。
・これらの動作が完了したら、webシステムに使用する予定のtweepyなども加えていきたい。
発生している問題・エラーメッセージ
**Internal Server Error** The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
該当のソースコード
python test_app.py
1from flask import Flask, redirect, render_template, render_template_string, request, url_for 2import numpy as np 3import pandas as pd 4 5app = Flask(__name__) 6 7@app.route('/') 8def index(): 9 return render_template('index.html') 10 11#---------------- 12#この部分でpandasの動作テストをしています。 13@app.route('/test') 14def pandas(): 15 str = pd.read_csv("〜.csv") #strは整数型リスト(仮) 16 text = str[0] 17 18 return text #イメージとしては"Hello World!"のような表示されたサイトが閲覧できる状態 19#----------------- 20 21if __name__ == '__main__': 22 app.run(debug=True)
index.cgi
1 2#! /home/xs020203/anaconda3/envs/[仮想環境名(ここにpandasが入っている)]/bin/python3.8 3from wsgiref.handlers import CGIHandler 4from test_app import app 5CGIHandler().run(app) 6
htaccess
1RewriteEngine On 2RewriteCond %{REQUEST_FILENAME} !-f 3RewriteRule ^(.*)$ /[作成フォルダ名]/index.cgi/$1 [QSA,L] 4
補足情報(FW/ツールのバージョンなど)
インストールしたanacondaバージョン
Anaconda3-2021.11-Linux-x86_64.sh
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。