jonhadfield / python-hosts

a hosts file manager library written in python
MIT License
125 stars 33 forks source link

python-hosts unable to install by pip, deprecated warnings on local install. #55

Open CookieThump opened 1 month ago

CookieThump commented 1 month ago

I wrote a script some days ago to modify my hostfile on my system importing python-hosts. It worked absolutely fine, but since I guess the 21th of september, don't remember 100%, I only get back errors.

When I try to execute the script, I get the following error:

from python_hosts import Hosts, HostsEntry
ModuleNotFoundError: No module named 'python_hosts'

When I try to install pyhton-hosts I get the following error:

Unable to locate package python_hosts

And when i try to install the package manually (after cloning the git) with setup.py, I get a bunch of errors like that:

python setup.py install
/usr/lib/python3/dist-packages/setuptools/dist.py:476: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!

        ********************************************************************************
        Usage of dash-separated 'description-file' will not be supported in future
        versions. Please use the underscore name 'description_file' instead.

        This deprecation is overdue, please update your project and remove deprecated
        calls to avoid build errors in the future.

        See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
        ********************************************************************************

!!
  opt = self.warn_dash_deprecation(opt, section)
running install
/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

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

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.12/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html

Please make the appropriate changes for your system and try again.

Do you know how to fix this? Is this a problem with my system or is python-hosts really unusable atm? Thanks in advance! :D

jonhadfield commented 1 month ago

Hi, the deprecation notices are valid and something I need to look at. It seems your issues relates to permissions: [Errno 13] Permission denied: '/usr/local/lib/python3.12/dist-packages/test-easy-install-102214.write-test' It suggests the user being used to install the application doesn't have access to the necessary files. You could either try changing ownership of those files, or running the install with sudo.

CookieThump commented 1 month ago

Hi, thank you! Installing with sudo worked, of course the deprecation warnings are still there but it's usable. :)