Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Issue #140

Closed
Tack-Tau opened this issue Jun 28, 2021 · 22 comments
Closed

Installation Issue #140

Tack-Tau opened this issue Jun 28, 2021 · 22 comments

Comments

@Tack-Tau
Copy link

I'm trying to install sumo using pip3 install --user sumo with Python@3.9
However although the sumo package is already installed, it cannot be invoked by which sumo-optplot

In the site-package folder I can find all these packages, so it is definitely properly installed by pip3

cd /usr/local/lib/python3.9/site-packages/
ls sumo
__init__.py          electronic_structure plotting
__pycache__          io                   symmetry
cli                  phonon

My current PATH for Python3 and pip3 is:

which python3 
/usr/local/opt/python@3.9/bin/python3

which pip3
/usr/local/opt/python@3.9/bin/pip3

I searched a little bit for solutions on the internet, none of them solved this issue.

1.I changed the environment variables for in the .bashrc and .bash_profile and sourced it

export PATH="/usr/local/opt/python@3.9/bin:$PATH"
export PYTHONPATH="/usr/local/lib/python3.9/site-packages/"

2.I changed file permission and attributes for site-packages folder

sudo chmod -R 755 /usr/local/lib/python3.9/site-packages/

3.I tried uninstall and reinstall Python@3.9 with Homebrew also brew unlink Python@3.9 follow with brew link Python@3.9, still won't help.

4.I tried uninstall and reinstall packages with pip3 install --user and Python3 -m pip install --user, still nothing changes.

Can anyone tell me the solution for this?

@utf
Copy link
Member

utf commented Jun 28, 2021

I would recommend installing sumo within a conda environment. In general, I've found conda a much more reliable way of managing python packages.

First I would install miniconda: https://docs.conda.io/en/latest/miniconda.html

Then you can create a new conda environment using:

conda create -n sumo python=3.8 pip

This will create an environment called "sumo" and install python 3.8 and pip.

The environment can "activated" (meaning you can access the installed packages) using:

conda activate sumo

And finally you can install sumo as normal using:

pip install sumo

@Tack-Tau
Copy link
Author

Is sumo compatible with python3.9 ? @utf

@ajjackson
Copy link
Member

Python 3.9 shouldn't be a problem.

I think you were on the right lines with trying to set PATH. Unfortunately, I can't know which directory your Python/homebrew setup installed the command-line tools into. One option is to use Conda as Alex suggested, which will set up the environment variables correctly.

But if you want to use the Homebrew Python and you already installed with --user, a likely location would be something like /Users/TackTau/.local/bin. Can you look in that ~/.local folder and see if you can find the tools in there somewhere?

@Tack-Tau
Copy link
Author

brew --prefix Python@3.9
/usr/local/opt/Python@3.9

@ajjackson

@ajjackson
Copy link
Member

This isn't necessarily where pip install --user sumo installs. Have you found the sumo-optplot binary yet?

@Tack-Tau
Copy link
Author

I found sumo folder in /usr/local/lib/python3.9/site-packages/sumo

cd /usr/local/lib/python3.9/site-packages/
ls sumo
__init__.py          electronic_structure plotting
__pycache__          io                   symmetry
cli                  phonon

@ajjackson

@ajjackson
Copy link
Member

This is the python library part; the command-line tools will always be in an another directory.

You may need to get help from someone familiar with your Python setup. This problem is not specific to Sumo but is a general challenge people encounter when installing Python packages on Mac OSX.

@Tack-Tau
Copy link
Author

Tack-Tau commented Jun 29, 2021

Just found these in Homebrew's Python documentation:

"For brewed Python, modules installed with pip3 or python3 setup.py install will be installed to the $(brew --prefix)/lib/pythonX. Y/site-packages directory (explained above). Executable Python scripts will be in $(brew --prefix)/bin"

Did you mean the location of Executable Python script? @ajjackson

cd $(brew --prefix)/bin
pwd
/usr/local/bin
find /usr/local/bin -name "sumo-*"

I did not find any sumo executable.

@ajjackson
Copy link
Member

Have you checked ~/.local yet?

@ajjackson
Copy link
Member

Just found these in Homebrew's Python documentation:

"For brewed Python, modules installed with pip3 or python3 setup.py install will be installed to the $(brew --prefix)/lib/pythonX. Y/site-packages directory (explained above). Executable Python scripts will be in $(brew --prefix)/bin"

This should be where it ends up if you install without --user.

@Tack-Tau
Copy link
Author

Tack-Tau commented Jun 29, 2021

This is site.USER_SITE on Python documentation

It's strange cause the user site-packages are empty although I installed sumo with python3 -m pip install --user
@ajjackson

cd ~/Library/Python/3.9
ls
lib
tree lib/
lib/
└── python
    └── site-packages

2 directories, 0 files

@ajjackson
Copy link
Member

The problem is that there are lot of places that USER_SITE can be set. So even if one location is documented, another Python distribution might set its own. I don't have access to a "clean" Mac to find out exactly what the latest Homebrew does by default; on my system it will interact in some unique way with the multiple other Python installations.

You still haven't confirmed if you checked in ~/.local yet? On my Mac the sumo scripts install to ~/.local/bin.

I still have no reason to believe the problem is related to Sumo; it seems that your scientific python environment is not configured correctly. Are you able to install other packages with executables via Pip, e.g. flake8?

@Tack-Tau
Copy link
Author

Tack-Tau commented Jun 29, 2021

There is no ~/.local directory on my Mac @ajjackson

I have phonopy successfully installed and can be invoked.

which phonopy
/usr/local/bin/phonopy

@ajjackson
Copy link
Member

ajjackson commented Jun 29, 2021

site-packages hold libraries, not scripts. Where is the phonopy script (try which phonopy) and how did you install it?

EDIT: Right, it was probably installed there with something like pip3 install phonopy. We recommend using --user because generally Pip defaults to installing in a system directory that is not writable without admin permissions. However, Homebrew cheats a bit and puts its stuff in /usr/local (because this is unused by default in MacOS), and makes /usr/local user-writable. (I don't really like this because it seems like a mess if you have multiple user accounts.) So with Homebrew's Python you could try pip3 install sumo and it will probably install to /usr/local/bin. It would be bad practice on Linux but it you're using Homebrew anyway and don't want to mess with environments I guess it's ok 🤷

@Tack-Tau
Copy link
Author

Actually I forgot how I installed it, LOL.
But I suppose phonopy is one of sumo dependencies ?

@Tack-Tau
Copy link
Author

I probably used Building using setup.py for phonopy

@Tack-Tau
Copy link
Author

Tack-Tau commented Jun 29, 2021

pip3 install sumo
Requirement already satisfied: sumo in /usr/local/lib/python3.9/site-packages (2.2.5)
Requirement already satisfied: numpy in /usr/local/lib/python3.9/site-packages (from sumo) (1.21.0)
Requirement already satisfied: spglib in /usr/local/lib/python3.9/site-packages (from sumo) (1.16.1)
Requirement already satisfied: castepxbin==0.1.0 in /usr/local/lib/python3.9/site-packages (from sumo) (0.1.0)
Requirement already satisfied: h5py in /usr/local/lib/python3.9/site-packages (from sumo) (3.3.0)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.9/site-packages (from sumo) (3.4.2)
Requirement already satisfied: pymatgen>=2020.10.20 in /usr/local/lib/python3.9/site-packages (from sumo) (2022.0.9)
Requirement already satisfied: phonopy>=2.1.3 in /usr/local/lib/python3.9/site-packages (from sumo) (2.10.0)
Requirement already satisfied: seekpath in /usr/local/lib/python3.9/site-packages (from sumo) (2.0.1)
Requirement already satisfied: scipy in /usr/local/lib/python3.9/site-packages (from sumo) (1.7.0)
Requirement already satisfied: PyYAML in /usr/local/lib/python3.9/site-packages (from phonopy>=2.1.3->sumo) (5.4.1)
Requirement already satisfied: ruamel.yaml>=0.15.6 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (0.17.10)
Requirement already satisfied: sympy in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (1.8)
Requirement already satisfied: networkx>=2.2 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (2.5.1)
Requirement already satisfied: monty>=3.0.2 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (2021.6.10)
Requirement already satisfied: uncertainties>=3.1.4 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (3.1.5)
Requirement already satisfied: tabulate in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (0.8.9)
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (2.25.1)
Requirement already satisfied: plotly>=4.5.0 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (5.0.0)
Requirement already satisfied: palettable>=3.1.1 in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (3.3.0)
Requirement already satisfied: pandas in /usr/local/lib/python3.9/site-packages (from pymatgen>=2020.10.20->sumo) (1.2.5)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.9/site-packages (from matplotlib->sumo) (8.2.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.9/site-packages (from matplotlib->sumo) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->sumo) (2.4.7)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.9/site-packages (from matplotlib->sumo) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->sumo) (1.3.1)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from cycler>=0.10->matplotlib->sumo) (1.15.0)
Requirement already satisfied: decorator<5,>=4.3 in /usr/local/lib/python3.9/site-packages (from networkx>=2.2->pymatgen>=2020.10.20->sumo) (4.4.2)
Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.9/site-packages (from plotly>=4.5.0->pymatgen>=2020.10.20->sumo) (7.0.0)
Requirement already satisfied: ruamel.yaml.clib>=0.1.2 in /usr/local/lib/python3.9/site-packages (from ruamel.yaml>=0.15.6->pymatgen>=2020.10.20->sumo) (0.2.4)
Requirement already satisfied: future in /usr/local/lib/python3.9/site-packages (from uncertainties>=3.1.4->pymatgen>=2020.10.20->sumo) (0.18.2)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.9/site-packages (from pandas->pymatgen>=2020.10.20->sumo) (2021.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests->pymatgen>=2020.10.20->sumo) (1.26.6)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.9/site-packages (from requests->pymatgen>=2020.10.20->sumo) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests->pymatgen>=2020.10.20->sumo) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests->pymatgen>=2020.10.20->sumo) (2020.6.20)
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.9/site-packages (from sympy->pymatgen>=2020.10.20->sumo) (1.2.1)

After I uninstalled it with python3 -m pip uninstall sumo and reinstalled it with pip3 install sumo
it gives me the error:

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/LICENSE'
Consider using the `--user` option or check the permissions.

@ajjackson
Copy link
Member

ajjackson commented Jun 29, 2021

Try to pip3 uninstall it as many times as you can so that there aren't multiple half-installed versions hanging around, then install again and see if it ended up in /usr/local/bin?

@ajjackson
Copy link
Member

Wow that looks pretty broken. It tried to copy the whole package into /usr/local and that's a terrible idea which was prevented for good reasons.

I'm really sorry but I can't do much more for you from here, I think you need to sit down with an experienced Mac/Python user who can figure out what is going on with your particular machine/environment.

@Tack-Tau
Copy link
Author

No, problem. I'll try conda or pipenv, do I need to uninstall Homebrew's Python3.9 before install it with conda ?

@ajjackson
Copy link
Member

Even if you do uninstall it, there will probably be some other useful Homebrew package that installs it again. I suggest making a habit to use which to ensure you are using the Python/Pip version you expected. The root of most of these problems is the existence of multiple Python installations on the same machine. While tools like conda and pyenv do a much better job of managing this, they can still clash with other installations on the same system.

@Tack-Tau
Copy link
Author

Great, thanks again for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants