从bluemix上的python库导入

2024-06-01 03:47:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要在IBM Bluemix上的Jupyter笔记本中使用以下导入

import swiftclient
from keystoneclient import client

如果我在本地工作站上,我可以使用pip安装库,但是如何在Bluemix上安装?另一篇文章建议在Python应用程序的根目录中添加一个requirements.txt文件和一个Procfile文件,但我不知道如何在笔记本上实现这一点。有什么建议吗?在

代码如下:

^{pr2}$

以下是错误消息:

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

我不知道它为什么抱怨pip版本。Bluemix不能控制吗?当我使用!pip install --upgrade pip时,它也抱怨这一点。一个多月来,我一直在努力让这个成功!非常令人沮丧。在


Tags: pipinfromsrcegglibpackagesusr
1条回答
网友
1楼 · 发布于 2024-06-01 03:47:48

您需要使用 user标志,因为作为用户,您不具有对系统的root访问权限。在

请尝试以下代码:

!pip install  user python-swiftclient
!pip install  user python-keystoneclient

但是,我可以从您的错误消息中看到您的服务实例非常旧。如果您切换到新产品“IBM数据科学经验”:http://datascience.ibm.com/

相关问题 更多 >