我需要在IBM Bluemix上的Jupyter笔记本中使用以下导入
...
moveable=False
...
如果我在我的本地工作站上,我可以使用pip来安装库,但是如何在Bluemix上执行?另一篇文章建议将import swiftclient
from keystoneclient import client
文件和Procfile文件添加到我的Python应用程序的根目录中,但我不知道如何使用笔记本执行此操作。有什么建议吗?
以下是代码:
requirements.txt
以下是错误消息:
#!pip install --upgrade pip
!pip install python-swiftclient
!pip install python-keystoneclient
import swiftclient
from keystoneclient import client
# Object Store credentials (generated by Insert to code)
credentials = {
'auth_url':'****',
'project':'****',
'project_id':'****',
'region':'dallas',
'user_id':'****',
'domain_id':'****',
'domain_name':'****',
'username':'****',
'password':"""****""",
'filename':'Warehousing-data.json',
'container':'notebooks',
'tenantId':'****'
}
# Establish Connection to Bluemix Object Store
connection = swiftclient.Connection(
key=credentials[password],
authurl=credentials[auth_url],
auth_version='3',
os_options={"project_id": credentials[projectId],
"user_id": credentials[userId],
"region_name": credentials[region]})
# The data files should now be accessible through calls of the form
# connection.get_object(credentials[container], fileName)[1]
# See https://developer.ibm.com/recipes/tutorials/using-ibm-object-storage-in-bluemix-with-python/
# and https://github.com/saviosaldanha/IBM_Object_Store_Python_Example/blob/master/storage_recipe_example.py
我不知道它为什么抱怨pip版本。 Bluemix不控制吗?当我使用You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting python-swiftclient
Using cached python_swiftclient-3.0.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): futures>=2.1.3 in /gpfs/global_fs01/sym_shared/YPProdSpark/user/sbf1-4c17d3407da8d0-a7ea98a5cc6d/.local/lib/python2.7/site-packages (from python-swiftclient)
Requirement already satisfied (use --upgrade to upgrade): requests>=1.1 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/requests-2.7.0-py2.7.egg (from python-swiftclient)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/six-1.9.0-py2.7.egg (from python-swiftclient)
Installing collected packages: python-swiftclient
Exception:
Traceback (most recent call last):
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 646, in install
**kwargs
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 310, in clobber
ensure_dir(destdir)
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 70, in ensure_dir
os.makedirs(path)
File "/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/swiftclient'
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): python-keystoneclient in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/python_keystoneclient-1.6.0-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): pbr<2.0,>=0.11 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): argparse in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/argparse-1.3.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): Babel>=1.3 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/Babel-1.3-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): iso8601>=0.1.9 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/iso8601-0.1.10-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): netaddr>=0.7.12 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/netaddr-0.7.15-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): oslo.config>=1.11.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/oslo.config-1.15.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): oslo.i18n>=1.5.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/oslo.i18n-1.5.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): oslo.serialization>=1.4.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/oslo.serialization-1.4.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): oslo.utils>=1.4.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/oslo.utils-1.9.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): PrettyTable<0.8,>=0.7 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/prettytable-0.7-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): requests>=2.5.2 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/requests-2.7.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/six-1.9.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): stevedore>=1.3.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/stevedore-1.6.0-py2.7.egg (from python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): pip in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg (from pbr<2.0,>=0.11->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): pytz>=0a in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/pytz-2015.4-py2.7.egg (from Babel>=1.3->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): msgpack-python>=0.4.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/msgpack_python-0.4.5-py2.7-linux-x86_64.egg (from oslo.serialization>=1.4.0->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): monotonic>=0.1 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/monotonic-0.2-py2.7.egg (from oslo.utils>=1.4.0->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): netifaces>=0.10.4 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/netifaces-0.10.4-py2.7-linux-x86_64.egg (from oslo.utils>=1.4.0->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): debtcollector>=0.3.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/debtcollector-0.5.0-py2.7.egg (from oslo.utils>=1.4.0->python-keystoneclient)
Requirement already satisfied (use --upgrade to upgrade): wrapt>=1.7.0 in /usr/local/src/bluemix_ipythonspark_16/notebook-2.7/lib/python2.7/site-packages/wrapt-1.10.5-py2.7-linux-x86_64.egg (from debtcollector>=0.3.0->oslo.utils>=1.4.0->python-keystoneclient)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-7298587a7c89> in <module>()
3 get_ipython().system(u'pip install python-keystoneclient')
4
----> 5 import swiftclient
6 from keystoneclient import client
7
ImportError: No module named swiftclient
时,它也抱怨了。我一直试图让这项工作超过一个月!非常令人沮丧。
答案 0 :(得分:0)
您需要使用--user
标志,因为您不能以root用户身份访问系统。
请尝试以下代码:
!pip install --user python-swiftclient
!pip install --user python-keystoneclient
但是,我可以从您那里看到错误消息,您服务实例已经很老了。如果您切换到新产品“IBM Data Science Experience”:http://datascience.ibm.com/
,那会更好