pip 安装火车失败

pip install trains fails

在 运行 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.

我知道I am not supposed to run under sudo when using a venv,所以我不是很明白这个问题

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

Python 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.

您有两个选择:

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

  2. 通过传递--user标志

    在用户主目录中安装你的包

    pip install --user

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

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

可能有一种提升其权限的方法,但我只是将其删除并通过

使用命令行创建了另一个
python -m virtualenv --python=/usr/bin/python3.7 venv

现在 pip install trains 成功了。

很烦人。

我在 Ubuntu 18.

中安装 matplotlib 时遇到了同样的错误

运行 这些行对我有用:

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

发现于 setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1