我正在使用 pythonanywere.com 来部署我的 Django 应用程序。所以我在那个虚拟环境中安装了一些机器学习库。
(venv) 19:16 ~ $ pip3 list
Package Version
--------------- ------------------
certifi 2018.4.16
chardet 3.0.4
DAWG-Python 0.7.2
Django 2.0.5
docopt 0.6.2
idna 2.6
numpy 1.14.3
pip 10.0.1
pymorphy2 0.8
pymorphy2-dicts 2.4.393442.3710985
python-dateutil 2.7.3
pytz 2018.4
scikit-learn 0.19.1
scipy 1.1.0
setuptools 39.1.0
six 1.11.0
sklearn 0.0
wheel 0.31.1
Run Code Online (Sandbox Code Playgroud)
但是当我尝试时python3 manage.py runserver我得到了这个
from sklearn.linear_model import SGDClassifier
File "/home/kirillkorolev/.virtualenvs/venv/lib/python3.6/site-packages/sklearn/__init__.py", line 134, in <module>
from .base import clone
File "/home/kirillkorolev/.virtualenvs/venv/lib/python3.6/site-packages/sklearn/base.py", line 11, in <module>
from scipy import sparse …Run Code Online (Sandbox Code Playgroud) 我的理解是pythonanywhere支持无头的Firefox浏览器但你需要
from pyvirtualdisplay import Display
Run Code Online (Sandbox Code Playgroud)
所以你可以使用连接
with Display():
while True:
try:
driver = webdriver.Firefox()
break
except:
time.sleep(3)
Run Code Online (Sandbox Code Playgroud)
我连接得很好.但是,在我开始使用驱动程序之后
with Display():
while True:
try:
driver = webdriver.Firefox()
break
except:
time.sleep(3)
wb=load_workbook(r'/home/hoozits728/mutual_fund_tracker/Mutual_Fund_Tracker.xlsx')
ws=wb.get_sheet_by_name('Tactical')
for i in range(3, ws.max_row+1):
if ws.cell(row=i,column=2).value is not None:
driver.get('https://finance.yahoo.com/quote/' + ws.cell(row=i,column=2).value + '/performance?ltr=1')
oneyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-child(2) > div > div:nth-child(5) > span:nth-child(2)').text
threeyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-of-type(2) > div > div:nth-of-type(6) > span:nth-of-type(2)').text
fiveyear=driver.find_element_by_css_selector('#Col1-0-Performance-Proxy > section > div:nth-of-type(2) > div > div:nth-of-type(7) > span:nth-of-type(2)').text
ws.cell(row=i,column=10).value=oneyear …Run Code Online (Sandbox Code Playgroud) python selenium pythonanywhere selenium-webdriver python-3.5
是否可以通过PythonAnywhere运行Ipython Notebook.这将是非常有用的.
我有一个带有文件系统的工作示例站点(https://github.com/alvations/APE):
APE
\app
\templates
base.html
index.html
instance.html
__init__.py
hamlet.py
config.py
run.py
Run Code Online (Sandbox Code Playgroud)
我在https://www.pythonanywhere.com上创建了一个烧瓶项目,文件系统是这样的:
/home/alvations/
/Dropbox/
/mysite/
/templates
base.html
index.html
instance.html
flask_app.py
/web2py/
Run Code Online (Sandbox Code Playgroud)

我run.py在哪里放置我的pythonanywhere项目?
如何在pythonanywhere上的Github中使用与我的项目相同的文件结构?
我试图导入一个模块,我不断得到一个ImportError.
在PortfolioStatus.py文件中,我有以下代码从share_data.py模块导入share_data类
from Shares.share_data import share_data
我收到以下错误:
File "/home/lucasamos/FYP/Shares/Communication/PortfolioStatus.py", line 3, in <module>
from Shares.share_data import share_data
ImportError: No module named Shares.share_data
Run Code Online (Sandbox Code Playgroud)
为了让事情更加混乱,这在我的本地机器上工作正常,但我在PythonAnywhere上托管,这是我得到错误的地方
我的文件层次结构如下图所示
提前致谢!
我试图在pythonanywhere上部署一个django项目,但是它给出了错误 -
(2003, "Can't connect to MySQL server on 'mysql.server' (111)")
我已经看到很多问题已经问过这个问题,但没有答案解决了我的问题.可能存在访问数据库的previlleges问题.
数据库设置是 -
Run Code Online (Sandbox Code Playgroud)DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mutechrobotics$mutech_db', 'USER': 'mutechrobotics', 'PASSWORD':'root', 'HOST': 'mysql.server', } }
在运行show grants命令后显示数据库(实际上我只需要一个数据库,但我无法删除额外的数据库)
mysql> show grants ;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mutechrobotics@% |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mutechrobotics'@'%' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH MAX_USER_CONNECTIONS 3 |
| GRANT ALL PRIVILEGES ON `mutechrobotics$default`.* TO 'mutechrobotics'@'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mutechnew_db`.* TO 'mutechrobotics'@'%' |
| GRANT …Run Code Online (Sandbox Code Playgroud) 我试图将数据从python 3.4输入到MySQL数据库中,而这两个实体都在pythonAnywhere内。换句话说,我正在pythonAnywhere中编写一个python 3.4程序,并且需要在pythonAnywhere中也连接到MySQL数据库。我在这里检查了其他答案,但还没有弄清楚。我已经尝试了一些帖子中提到的(-u -h -p)语法,但是我不确定这是否只是为了从pythonAnywhere外部获取访问权限。任何帮助,将不胜感激。
++++++++++++++++++++++
import MySQLdb
db=MySQLdb.connect(
host='Your_User_Name.mysql.pythonanywhere-services.com',
user='Your_User_Name',
passwd='Your_pythonAnywhere_password',
db='Your_User_Name$Your_Data_Base')
Run Code Online (Sandbox Code Playgroud)
cursor = db.cursor ()
Run Code Online (Sandbox Code Playgroud)
cursor.execute ("Enter any MySQL query here. use the quotes. no semi-colon")
Run Code Online (Sandbox Code Playgroud)
row = cursor.fetchone ()
print(row)
Run Code Online (Sandbox Code Playgroud)
data = cursor.fetchall()
print(data)
Run Code Online (Sandbox Code Playgroud)
cursor.close ()
Run Code Online (Sandbox Code Playgroud)
db.close ()
Run Code Online (Sandbox Code Playgroud) 我想将 pythonanywhere 项目与 github 帐户同步。就像如果我在 github 上对我的项目进行更改,它会在 pythonanywhere 自动更新。原谅我是 github 的新手。
我是python的新手,仍在学习。我在 pythonanwhere 上创建了一个小的 python 3.6 Flask webapp,发现 send_file() 在 pythonanywhere 服务器上不起作用。我正在积极寻找直接在用户计算机上下载 excel 文件的替代方法。我也试过Response但它没有提供所需的输出。我在网上阅读了很多关于它的内容,发现如果我们在下面设置,send_file 可以正常工作
wsgi-disable-file-wrapper = True
但是,我不知道在哪里设置它,因为我找不到可以更新此行的 uWsgi.ini 文件。
以下是我尝试过但失败的方法,请帮助
SEND_FILE() 配置: ->>> 未运行..
output = BytesIO()
writer = pd.ExcelWriter(output, engine='xlsxwriter')
workbook = writer.book
output.seek(0)
return send_file(output,attachment_filename="testing.xlsx",as_attachment=True)
Run Code Online (Sandbox Code Playgroud)
输出错误:
return environ.get('wsgi.file_wrapper', FileWrapper)(file, buffer_size)
SystemError: <built-in function uwsgi_sendfile> returned a result with an error set
Run Code Online (Sandbox Code Playgroud)
使用响应配置:
writer = pd.ExcelWriter("abc.xlsx", engine='xlsxwriter')
return Response(writer,mimetype="text/csv",headers={"Content-disposition":"attachment; filename=myplot.csv"})
Run Code Online (Sandbox Code Playgroud)
输出错误:
Error running WSGI application
TypeError: '_XlsxWriter' object is not iterable
File "/home/hridesh1987/.virtualenvs/myproject/lib/python3.6/site-packages/werkzeug/wsgi.py", line 870, in …Run Code Online (Sandbox Code Playgroud) 我尝试根据说明在 Java 程序中使用 SSH 与 PythonAnywhere 中的 MySQL 库建立连接: https:
//help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere
不幸的是,我每次都会遇到这个错误,而且我已经没有想法了:
com.jcraft.jsch.JSchException:拒绝主机密钥:ssh.pythonanywhere.com
public static void main(String[] args) {
Tunnel tunnel = new Tunnel();
try {
tunnel.go();
} catch (Exception e) {
e.printStackTrace();
}
}
public void go() throws Exception {
String host = "ssh.pythonanywhere.com";
String user = "username";
String password = "password";
int port = 22;
int tunnelLocalPort = 9080;
String tunnelRemoteHost = "username.mysql.pythonanywhere-services.com";
int tunnelRemotePort = 3306;
JSch jsch= new JSch();
Session session = jsch.getSession(user,host,port);
localUserInfo lui = …Run Code Online (Sandbox Code Playgroud) pythonanywhere ×10
python ×5
flask ×2
mysql ×2
python-3.x ×2
django ×1
git ×1
github ×1
java ×1
jsch ×1
pip ×1
python-2.7 ×1
python-3.4 ×1
python-3.5 ×1
scipy ×1
selenium ×1
ssh ×1
ssh-tunnel ×1
x-sendfile ×1