python - 我正在尝试安装 ipython 但出现权限错误

标签 python ipython python-3.5

我使用命令 pip3 install ipython 但出现这些错误 我需要安装 virtualenv 吗?

Exception:
Traceback (most recent call last):
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/IPython'

最佳答案

错误消息揭示了问题:您无权写入该文件夹,因为 /usr/... 是系统文件夹。

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/IPython'

您需要使用sudo进行全局安装,或者仅使用--user选项安装它们,该选项仅为当前用户而不是所有人安装软件包:

pip install ipython --user

或者也许更好的选择是使用 virtual environment它为您隔离软件包。

关于python - 我正在尝试安装 ipython 但出现权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46599436/

相关文章:

python - django 从 View 重定向到 iframe 的父级

Python Plotly - 对齐散点图和条形图的 Y 轴

python - 如何在 IPython 中使用全局变量

windows-10 - Windows 10 上的 Python 脚本

python - 连接numpy数组切片的最快方法

python - 我应该先 train_test_split 然后使用交叉验证吗?

python-3.x - 导入错误 : cannot import name 'Pdb' from 'IPython.core.debugger'

python - Matplotlib 在方法和日期时间之间填充

tensorflow - Tensorflow 中的 while_loop 错误

python - 崇高文本 3 : Anaconda package error connection to localhost timed out