简体   繁体   中英

pip install trains fails

upon running pip install trains in my virtual env

I am getting

    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 know that I am not supposed to run under sudo when using a venv , so I don't really understand the problem

running for example pip install pandas does work.

Python 3.8

How to install trains?


EDIT:

running pip install trains --user or pip install --user trains gives

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

You have two options:

  1. Create a virtual environment and install your packages inside it (preferred)

  2. Install your packages inside your user home directory by passing --user flag

    pip install --user

The problem was a permissions problem for the venv. Another problem was trains required some packages that were not yet available with wheels on Python3.8, so I had to downgrade Python to 3.7

That venv was created using Pycharm, and for some reason it was created with low permissions.

There was probably a way to elevate its permissions, but instead I just deleted it and created another one using command line by

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

And now pip install trains worked.

Very annoying.

I had the same error with installing matplotlib in Ubuntu 18.

Running these lines worked for me:

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

As found on setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM