causalincentives / pycid

Library for graphical models of decision making, based on pgmpy and networkx
Apache License 2.0
96 stars 13 forks source link

Issues with installing on Ubuntu #42

Closed kholtman closed 3 years ago

kholtman commented 3 years ago

..just tried to install pycid on my Ubuntu (20.04) system. I ran into some problems following the current instructions, figure I should report them so that they can be improved. The current instructions are:

git clone https://github.com/causalincentives/pycid # download the code cd pycid pip3 install --editable .[test] python3 -m pytest # check that everything works

Minor problems: I had to do

sudo apt install python3-pip sudo apt install python3-testresources

to get some needed python3 components.

More significantly,

pip3 install --editable .[test]

did not create a fully working install, but produced a long error message including:

   [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/test-easy-install-11670.write-test'

Digging down, the clean solution to this would have been to add the option -t ~/.local/lib/python3.8/ to the pip3 command line, but this does not work, as for some reason --editable is incompatible with using the -t ~/.local/lib/python3.8/ option, see for example here: https://github.com/pypa/pip/issues/4390 . So in terms of updating the pycid installation instructions to help Ubuntu users, I have identified two possible solution paths leading to a clean install:

Solution 1 (not recommended on multiuser systems): change permissions on /usr/local/lib/python3.8/dist-packages/ to make it writable, e.g. do

sudo chown `whoami` /usr/local/lib/python3.8/dist-packages/

before running the pip3 install command.

Solution 2: omit the --editable flag and do:

pip3 install .[test]

This copies the cloned repository files to ~/.local/lib/python3.8/site-packages/ , so less useful if you want to edit these files in developer mode.

edlanglois commented 3 years ago

I strongly recommend against chown /usr/local/lib/python3.8/dist-packages/, even on single user systems. You probably want let your package manager manage that and not mess with system packages.

I'll clarify this in the README but the options I recommend are: Option 1 for development Create and activate a virtual environment then install to the virtual environment with

pip3 install --editable .[test]

Option 2 for development Install to $HOME. This doesn't let you specify [test] so those packages have to be installed manually.

python3 setup.py develop --user
pip3 install --user flake8 ipykernel mypy nbconvert nbformat pep8-naming pytest

And for non-development usage: Option 1 for users Coming soon. Create a virtual environment and run

pip3 install pycid

or pip3 install --user pycid if not using a virtual environment.

Option 2 for users

pip3 install .  # If in a virtual environment
#or
pip3 install --user . # If not in a virtual environment
edlanglois commented 3 years ago

Another option is to use a conda environment.

Closing since the suggestion to use a virtual environment or conda is now in the README.

kholtman commented 3 years ago

Thanks! Tried the new instructions with a virtual environment on my Ubuntu box (with /usr/local/lib/python3.8/dist-packages/ owned by root again, as default in an Ubuntu install) and I can confirm it works.