我在这里遵循了一个教程:https://tinyfox.rocks/2019/03/18/Install-Python-Dash-App-on-an-Ubuntu-Server/来设置一个Web服务器,该服务器将把我在Dash中制作的图表暴露给外部用户(只有1个,并且被认为是dev,而不是生产版本),而Im则有问题。
错误是: ModuleNotFoundError:没有名为“ pandas”的模块,引用:http://192.168.1.55:8080/
位于虚拟目录中我的app.py中
/etc/apache2/sites-available/FlaskApp.conf
ServerName 192.168.1.55
ServerAdmin youremail@email.com
WSGIScriptAlias / /var/www/FlaskApp/FlaskApp.wsgi
<Directory /var/www/FlaskApp/deribit-charting/>
Order allow,deny
Require all granted
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/FlaskApp-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/FlaskApp-access.log combined
</VirtualHost>
/var/www/FlaskApp/FlaskApp.wsgi
#!/usr/bin/python3.6
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/var/www/FlaskApp/deribit-charting/")
from app import app
application = app.server
冻结点显示:
pandas==0.25.0
和app.py文件开始如下:
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
app = dash.Dash(name='app')
server = app.server
现在,app.py导入一个调用
的db.py文件。import config
import pandas as pd
import datetime as dt
from sqlalchemy import and_
from sqlalchemy.orm import sessionmaker, Session
from sqlalchemy.ext.declarative import declarative_base
import sqlalchemy as db
我认为这才是真正的问题所在。这意味着我的应用程序的一部分实际上正在加载,但是找不到熊猫。我没有类似pipenv或docker的东西。该服务器是为此1个应用程序构建的。
编辑:
xxx@ubuntuserver:/tmp$ pip3 install pandas
Requirement already satisfied: pandas in /home/xxx/.local/lib/python3.6/site-packages (0.25.0)
Requirement already satisfied: pytz>=2017.2 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (2019.1)
Requirement already satisfied: numpy>=1.13.3 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (1.16.4)
Requirement already satisfied: python-dateutil>=2.6.1 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (2.8.0)
Requirement already satisfied: six>=1.5 in /home/xxx/.local/lib/python3.6/site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)
xxx@ubuntuserver:/tmp$ pip install pandas
Requirement already satisfied: pandas in /home/xxx/.local/lib/python3.6/site-packages (0.25.0)
Requirement already satisfied: pytz>=2017.2 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (2019.1)
Requirement already satisfied: numpy>=1.13.3 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (1.16.4)
Requirement already satisfied: python-dateutil>=2.6.1 in /home/xxx/.local/lib/python3.6/site-packages (from pandas) (2.8.0)
Requirement already satisfied: six>=1.5 in /home/xxx/.local/lib/python3.6/site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)
编辑2:
python3
xxx@ubuntuserver:/tmp$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/theskaz/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
>>> sys.version_info
sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)
python2
xxx@ubuntuserver:/tmp$ python
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=15, releaselevel='final', serial=0)
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']