You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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).
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.
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).
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 ™️ .
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))
So, my configuration file is not being found, although it does exist in the
default location.
On Mon, Aug 17, 2020 at 1:13 PM P. L. Lim ***@***.***> wrote:
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 ™️ .
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIEDRAKBL2DO7W76XZSTALSBGFPBANCNFSM4QASBQJA>
.
The more serious problem for me is that my script dies when it attempts to
import (directly or indirectly) from astropy:
```
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))
WARNING: CacheMissingWarning: Remote data cache could not be accessed due
to FileNotFoundError:
[WinError 53] The network path was not found: '\\\\<omitted>\\.astropy'
[astropy.utils.data]
Downloading https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
|===========================================| 1.3k/1.3k (100.00%) 0s
WARNING: ConfigurationMissingWarning: Configuration defaults will be used
due to FileNotFoundError:2 on None [astropy.config.configuration]
Traceback (most recent call last):
File "STK.py", line 49, in <module>
from poliastro.twobody import Orbit
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\poliastro\twobody\__init__.py",
line 1, in <module>
from .orbit import Orbit
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\poliastro\twobody\orbit.py",
line 15, in <module>
from astroquery.jplhorizons import Horizons
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astroquery\jplhorizons\__init__.py",
line 216, in <module>
from .core import Horizons, HorizonsClass
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astroquery\jplhorizons\core.py",
line 1302, in <module>
Horizons = HorizonsClass()
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astroquery\jplhorizons\core.py",
line 86, in __init__
super(HorizonsClass, self).__init__()
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astroquery\query.py",
line 162, in __init__
paths.get_cache_dir(), 'astroquery',
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astropy\config\paths.py",
line 173, in get_cache_dir
return os.path.abspath(_find_or_create_root_dir('cache', linkto,
rootname))
File
"C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\astropy\config\paths.py",
line 298, in _find_or_create_root_dir
os.mkdir(innerdir)
FileNotFoundError: [WinError 53] The network path was not found:
'\\\\<omitted>\\UserID\\.astropy'
```
It is unclear to my why Astropy is searching a network path.
After talking to some of our multi-platform developers, I understand the
problem. I was told that HOMESHARE should be used on Linux, and
USERPROFILE should be used on Windows. This is apparently a fairly common
mistake for developers who work exclusively on Linux. Is there any
possibility of getting this changed? (HOMESHARE is defined on some Windows
machines, but is set via Active Directory and essentially hardwired, so
that users--even with administrative rights--cannot change the value).
On Tue, Sep 1, 2020 at 9:31 AM P. L. Lim ***@***.***> wrote:
So, in astropy, this is only a warning and doesn't stop anything from
running. But astroquery promotes it to an exception because astroquery
likes caching.
And based on this Windows logic:
https://github.com/astropy/astropy/blob/659ea8c708379a3e76f445f50bfbe1e4270ef668/astropy/config/paths.py#L42-L48
It tries to use HOMESHARE (as far as I can see based on what is posted
above) and fails because your network drive is unavailable for whatever
reason. So, here are my suggestions (better ones are certainly welcome):
1. Define MSYSTEM *and* HOME. Point HOME to some local drive where you
want to cache to be stored; *-- OR --*
2. Change HOMESHARE to point to some local drive where you want to
cache to be stored.
On my Windows in a Git Bash shell, this is what it looks like for me:
$ echo $MSYSTEM
MINGW64
$ echo $HOME
/c/Users/username
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIEDREQ5EKYX7Y5ROCFDWLSDUOUZANCNFSM4QASBQJA>
.
If I go the MSYSTEM and HOME route, how should MSYSTEM be set? Note that
neither of these is a standard Windows environment variable.
On Tue, Sep 1, 2020 at 8:31 PM Phillip Feldman <[email protected]>
wrote:
After talking to some of our multi-platform developers, I understand the
problem. I was told that HOMESHARE should be used on Linux, and
USERPROFILE should be used on Windows. This is apparently a fairly common
mistake for developers who work exclusively on Linux. Is there any
possibility of getting this changed? (HOMESHARE is defined on some Windows
machines, but is set via Active Directory and essentially hardwired, so
that users--even with administrative rights--cannot change the value).
On Tue, Sep 1, 2020 at 9:31 AM P. L. Lim ***@***.***> wrote:
> So, in astropy, this is only a warning and doesn't stop anything from
> running. But astroquery promotes it to an exception because astroquery
> likes caching.
>
> And based on this Windows logic:
>
>
> https://github.com/astropy/astropy/blob/659ea8c708379a3e76f445f50bfbe1e4270ef668/astropy/config/paths.py#L42-L48
>
> It tries to use HOMESHARE (as far as I can see based on what is posted
> above) and fails because your network drive is unavailable for whatever
> reason. So, here are my suggestions (better ones are certainly welcome):
>
> 1. Define MSYSTEM *and* HOME. Point HOME to some local drive where
> you want to cache to be stored; *-- OR --*
> 2. Change HOMESHARE to point to some local drive where you want to
> cache to be stored.
>
> On my Windows in a Git Bash shell, this is what it looks like for me:
>
> $ echo $MSYSTEM
> MINGW64
> $ echo $HOME
> /c/Users/username
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#10661 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAIEDREQ5EKYX7Y5ROCFDWLSDUOUZANCNFSM4QASBQJA>
> .
>
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.
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:\\.
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.
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.
This is excellent news. Thanks!
When I search via anaconda.org, the most recent version of astropy that I
see is 4.0.1.post1, which I already have. How can I install the more
recent version?
On Tue, Sep 22, 2020 at 10:23 AM E. M. Bray ***@***.***> wrote:
With #10705 <#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 <https://github.com/Phillip-M-Feldman> Feel free to
follow up here if you have any more questions or concerns.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIEDRFMSIJ3RFGPXKXE7QLSHDMRJANCNFSM4QASBQJA>
.
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.
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
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
Activity
Phillip-M-Feldman commentedon Aug 16, 2020
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).
pllim commentedon Aug 17, 2020
C:\Users.astropy\config-- Is the period supposed to be there?Phillip-M-Feldman commentedon Aug 17, 2020
saimn commentedon Aug 17, 2020
Your config file should be in
$XDG_CONFIG_HOME/astropy.embray commentedon Aug 17, 2020
As @saimn noted, if
XDG_CONFIG_HOMEis set, the config file would be under$XDG_CONFIG_HOME/astropy. However,$XDG_CONFIG_HOMEis 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 defaultC:\Users\<Username>\.astropy\configwill be the right path for the config files on Windows.pllim commentedon Aug 17, 2020
@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!
saimn commentedon Aug 17, 2020
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).pllim commentedon Aug 17, 2020
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 ™️ .
Phillip-M-Feldman commentedon Aug 17, 2020
Phillip-M-Feldman commentedon Aug 18, 2020
embray commentedon Aug 18, 2020
The warning is bubbling up from this call to
get_config_dir():astropy/astropy/config/configuration.py
Line 574 in be39265
That's why the warning message says
None. Because if an exception occurred at this line,cfgfnisNone. This alone is definitely a bug.embray commentedon Aug 18, 2020
@Phillip-M-Feldman Could you please paste the output of
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.
9 remaining items
Phillip-M-Feldman commentedon Sep 2, 2020
Phillip-M-Feldman commentedon Sep 2, 2020
pllim commentedon Sep 2, 2020
Re: MSYSTEM
Try set it to
MINGW64and 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!
pllim commentedon Sep 2, 2020
Also, seems like #8731 might be related.
pllim commentedon Sep 2, 2020
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:\\.embray commentedon Sep 5, 2020
On #10570 there was some discussion as to whether all of the messy logic in the
_find_homefunction could simply be replaced with a call toos.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 whereos.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.embray commentedon Sep 5, 2020
@pllim Oops, I see you opened #10705 for this. I got my wires crossed since #10705 and #10570 are permutations of each other :)
embray commentedon Sep 22, 2020
With #10705 merged I think we can close this issue.
To summarize:
By default, on Windows, the astropy config directory will go to
~/.astropy/configwhere how~is interpreted by default on Windows is documented at: https://docs.python.org/3.7/library/os.path.html#os.path.expanduserHOMESHAREwill 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 likeC:\Users\<Username>\config, and under that theC:\Users\<Username>\config\astropydirectory should exist, but the\astropyis 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.
Phillip-M-Feldman commentedon Sep 25, 2020
pllim commentedon Sep 25, 2020
If you insist to use
conda installonly the version released toconda, then I am afraid you have to wait a few months for 4.2. If you are more adventurous, you can trypip 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.ReeceHumphreys commentedon Mar 30, 2022
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@mainjames8128 commentedon Jan 7, 2025
After hours of googling, only your solution could solve my problem. Thanks a lot
neutrinoceros commentedon Jan 7, 2025
@james8128 did you encounter this issue with astropy 7.0.0 ?