1

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.
DalyaG
  • 2,979
  • 2
  • 16
  • 19
Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • Looks like you've already borked your venv by running commands as root while having venv activated. Restore the ownership: run `id -un` to get the name, `id -gn` to get the group, then `sudo chown -R name:grp /home/epdadmin/noam/code/venv_linux/`, substituting `name` and `grp` with values you've obtained earlier. Then retry `pip install trains` – hoefling Oct 11 '20 at 18:02
  • `pip install pandas` probably only works because you already have `pandas` installed, so `pip` doesn't do anything. Try e.g. `pip install pandas --force-reinstall`, most probably it will also fail. – hoefling Oct 11 '20 at 18:04
  • @hoefling force reinstall did not fail – Gulzar Oct 12 '20 at 07:31

3 Answers3

1

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

Gulzar
  • 23,452
  • 27
  • 113
  • 201
Ankit Jaiswal
  • 22,859
  • 5
  • 41
  • 64
  • Thanks. 1. I am already in a virtual environment, will edit now (although it is in the logs). 2. I have tried, and getting `ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.` – Gulzar Oct 11 '20 at 15:55
  • @Gulzar can you uninstall `retrying` package and re-try? – Ankit Jaiswal Oct 11 '20 at 16:24
  • How? I will type the commands you tell me to. I am a long time Windows user, I just need to get my Python to work on a remote linux machine, so don't really know linux commands out of my head – Gulzar Oct 11 '20 at 16:25
  • @Martin.B same error when trying to `pip install retrying` after uninstalling. How do I solve this permission issue? it only happens on some installations, and not others. – Gulzar Oct 12 '20 at 10:04
1

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.

Gulzar
  • 23,452
  • 27
  • 113
  • 201
0

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

Peurke
  • 189
  • 3
  • 7