1

pip install trains在我的虚拟环境中运行时

我正进入(状态

    ERROR: Command errored out with exit status 1:
     command: /home/epdadmin/noam/code/venv_linux/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-owzh8lnl/retrying/setup.py'"'"'; __file__='"'"'/tmp/pip-install-owzh8lnl/retrying/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-lxz5t8pu/install-record.txt --single-version-externally-managed --compile --install-headers /home/epdadmin/noam/code/venv_linux/include/site/python3.8/retrying
         cwd: /tmp/pip-install-owzh8lnl/retrying/
    Complete output (10 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib
    copying retrying.py -> build/lib
    running install_lib
    copying build/lib/retrying.py -> /home/epdadmin/noam/code/venv_linux/lib/python3.8/site-packages
    byte-compiling /home/epdadmin/noam/code/venv_linux/lib/python3.8/site-packages/retrying.py to retrying.cpython-38.pyc
    error: [Errno 13] Permission denied: '/home/epdadmin/noam/code/venv_linux/lib/python3.8/site-packages/__pycache__/retrying.cpython-38.pyc.139678407381360'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/epdadmin/noam/code/venv_linux/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-owzh8lnl/retrying/setup.py'"'"'; __file__='"'"'/tmp/pip-install-owzh8lnl/retrying/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-lxz5t8pu/install-record.txt --single-version-externally-managed --compile --install-headers /home/epdadmin/noam/code/venv_linux/include/site/python3.8/retrying Check the logs for full command output.

我知道在使用 venv 时我不应该在 sudo 下运行,所以我不太明白这个问题

例如运行pip install pandas确实有效。

蟒蛇 3.8

如何安装火车?


编辑:

跑步pip install trains --userpip install --user trains给予

ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
4

3 回答 3

1

你有两个选择:

  1. 创建一个虚拟环境并在其中安装你的包(首选)

  2. 通过传递 --user 标志将软件包安装在用户主目录中

    pip install --user

于 2020-10-11T15:49:13.817 回答
1

问题是 venv 的权限问题。另一个问题是火车需要一些 Python3.8 上还没有轮子的包,所以我不得不将 Python 降级到 3.7

该 venv 是使用 Pycharm 创建的,出于某种原因,它是在低权限下创建的。

可能有一种方法可以提升其权限,但我只是删除了它并使用命令行创建了另一个

python -m virtualenv --python=/usr/bin/python3.7 venv

现在pip install trains工作了。

很烦人。

于 2020-10-15T13:18:50.970 回答
0

我在 Ubuntu 18 中安装 matplotlib 时遇到了同样的错误。

运行这些行对我有用:

sudo apt-get install python3-dev
apt-get install build-essential

如在安装脚本中发现的错误退出:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1

于 2021-12-25T06:45:01.537 回答