Skip to content

config folder/file not found #10661

Closed

Description

@Phillip-M-Feldman

On a Windows 10 computer, when I issue the command from astropy.config import get_config_dir, I get the following error:

C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astropy\config\configuration.py:557:
ConfigurationMissingWarning: Configuration defaults will be used due to FileNotFoundError:2 on
None warn(ConfigurationMissingWarning(msg))

But, I have set XDG_CONFIG_HOME=C:\Users.astropy\config, where USERID is my user ID, and there is a valid configuration file in that folder.

Activity

  1. Phillip-M-Feldman commented on Aug 16, 2020

    @Phillip-M-Feldman
    Author

    Because the import fails, it seems as though there is no way to determine where Astropy is looking for the config folder (or where it got that path from).

  2. pllim commented on Aug 17, 2020

    @pllim
    Member

    C:\Users.astropy\config -- Is the period supposed to be there?

  3. Phillip-M-Feldman commented on Aug 17, 2020

    @Phillip-M-Feldman
    Author
  4. saimn commented on Aug 17, 2020

    @saimn
    Contributor

    Your config file should be in $XDG_CONFIG_HOME/astropy.

  5. embray commented on Aug 17, 2020

    @embray
    Member

    As @saimn noted, if XDG_CONFIG_HOME is set, the config file would be under $XDG_CONFIG_HOME/astropy. However, $XDG_CONFIG_HOME is more of a UNIX standard and doesn't make a lot of sense to use on Windows. You're better off not setting it at all, since by default C:\Users\<Username>\.astropy\config will be the right path for the config files on Windows.

  6. pllim commented on Aug 17, 2020

    @pllim
    Member

    @Phillip-M-Feldman , did the answers resolve your issue? If so, please close this issue. If not, please let us know what else isn't working. Thanks!

  7. saimn commented on Aug 17, 2020

    @saimn
    Contributor

    There is maybe another issue if the default (without setting XDG_CONFIG_HOME) did not work. And I guess the error message does not help to identify the problem ;) (FileNotFoundError:2 on None warn(ConfigurationMissingWarning(msg)) is a bit cryptic).

  8. pllim commented on Aug 17, 2020

    @pllim
    Member

    On my Windows machine, I never had to set any special variables. I use Miniconda + Git Bash, install astropy (either released or dev) into a non-base environment there, and things Just Work ™️ .

  9. Phillip-M-Feldman commented on Aug 17, 2020

    @Phillip-M-Feldman
    Author
  10. Phillip-M-Feldman commented on Aug 18, 2020

    @Phillip-M-Feldman
    Author
  11. embray commented on Aug 18, 2020

    @embray
    Member

    The warning is bubbling up from this call to get_config_dir():

    cfgfn = path.join(get_config_dir(rootname=rootname), pkgname + '.cfg')

    That's why the warning message says None. Because if an exception occurred at this line, cfgfn is None. This alone is definitely a bug.

  12. embray commented on Aug 18, 2020

    @embray
    Member

    @Phillip-M-Feldman Could you please paste the output of

    import os, pprint
    pprint.pprint(os.environ)

    from your Python interpreter? Make sure to censor out anything private that might be in your environment.

    I wonder if this is related to #10570.

  13. 9 remaining items

  14. Phillip-M-Feldman commented on Sep 2, 2020

    @Phillip-M-Feldman
    Author
  15. Phillip-M-Feldman commented on Sep 2, 2020

    @Phillip-M-Feldman
    Author
  16. pllim commented on Sep 2, 2020

    @pllim
    Member

    Re: MSYSTEM

    Try set it to MINGW64 and see if anything breaks. If nothing on your machine is using it, it shouldn't matter what the value is. It just have to exist.

    Re: HOMESHARE vs USERPROFILE

    Fixing this might break some other person's set up, so any fix won't be in a backport anyway (you won't see it released soon). I do agree that maybe the logic should check for all the local stuff first before trying the network. I'll see if I can work out a PR.

    We apologize for any inconvenience caused!

  17. pllim commented on Sep 2, 2020

    @pllim
    Member

    Also, seems like #8731 might be related.

  18. pllim commented on Sep 2, 2020

    @pllim
    Member

    Do you want to see if #10705 would work for you? With that patch, if MSYSTEM isn't there, it would have checked for HOMEDRIVE + HOMEPATH next, which for your case, it would be P:\\.

  19. embray commented on Sep 5, 2020

    @embray
    Member

    On #10570 there was some discussion as to whether all of the messy logic in the _find_home function could simply be replaced with a call to os.path.expanduser('~') on both POSIX systems and Windows.

    No consensus was immediately reached on this before the PR was merged, so the use of os.path.expanduser('~') was only targeted to the case where os.name == 'posix', so this is of no immediate benefit to @Phillip-M-Feldman .

    The open question was whether the behavior of os.path.expanduser('~') is also an appropriate default on Windows. As I explained in the PR, I believe it is, and that all the Windows-specific logic should be removed and delegated to the default behavior provided by Python (rather than checking all these different environment variables ourselves). I guess this will require a follow-up PR.

  20. self-assigned this
    on Sep 5, 2020
  21. embray commented on Sep 5, 2020

    @embray
    Member

    @pllim Oops, I see you opened #10705 for this. I got my wires crossed since #10705 and #10570 are permutations of each other :)

  22. embray commented on Sep 22, 2020

    @embray
    Member

    With #10705 merged I think we can close this issue.

    To summarize:

    • By default, on Windows, the astropy config directory will go to ~/.astropy/config where how ~ is interpreted by default on Windows is documented at: https://docs.python.org/3.7/library/os.path.html#os.path.expanduser

    • HOMESHARE will not be used when determining the home directory on Windows.

    • You can still change the location of the config, even on Windows, by setting XDG_CONFIG_HOME, but this should be something like C:\Users\<Username>\config, and under that the C:\Users\<Username>\config\astropy directory should exist, but the \astropy is not part of the environment variable value (You can use any path you want though, I just used ``C:\Users<Username>\config` as an example.

    @Phillip-M-Feldman Feel free to follow up here if you have any more questions or concerns.

  23. Phillip-M-Feldman commented on Sep 25, 2020

    @Phillip-M-Feldman
    Author
  24. pllim commented on Sep 25, 2020

    @pllim
    Member

    If you insist to use conda install only the version released to conda, then I am afraid you have to wait a few months for 4.2. If you are more adventurous, you can try pip install git+https://github.com/astropy/astropy.git@master. For the latter, I recommend you try it out in a fresh and independent conda environment first.

  25. ReeceHumphreys commented on Mar 30, 2022

    @ReeceHumphreys

    Stumbled onto this, if you need the latest astropy build from GitHub using pip the command is pip install git+https://github.com/astropy/astropy.git@main

  26. james8128 commented on Jan 7, 2025

    @james8128

    Stumbled onto this, if you need the latest astropy build from GitHub using pip the command is pip install git+https://github.com/astropy/astropy.git@main

    After hours of googling, only your solution could solve my problem. Thanks a lot

  27. neutrinoceros commented on Jan 7, 2025

    @neutrinoceros
    Contributor

    @james8128 did you encounter this issue with astropy 7.0.0 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions