在 Google Dataproc 上启动 Jupyter Notebook 时,导入模块失败。我尝试使用不同的命令安装模块。一些例子:
import os
os.sytem("sudo apt-get install python-numpy")
os.system("sudo pip install numpy") #after having installed pip
os.system("sudo pip install python-numpy") #after having installed pip
import numpy
上述示例均不起作用并返回导入错误:
在此输入图像描述 https://i.stack.imgur.com/qtJEC.png
使用命令行时,我可以安装模块,但仍然存在导入错误。我想我将模块安装在错误的位置。
有什么想法吗?
我找到了解决方案。
import sys
sys.path.append('/usr/lib/python2.7/dist-packages')
os.system("sudo apt-get install python-pandas -y")
os.system("sudo apt-get install python-numpy -y")
os.system("sudo apt-get install python-scipy -y")
os.system("sudo apt-get install python-sklearn -y")
import pandas
import numpy
import scipy
import sklearn
如果有人有更优雅的解决方案,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)