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

KeyError: 'PROJ_LIB' #428

Closed
am-thyst opened this issue Oct 13, 2018 · 11 comments
Closed

KeyError: 'PROJ_LIB' #428

am-thyst opened this issue Oct 13, 2018 · 11 comments

Comments

@am-thyst
Copy link

Just created a whole new environment and had to reinstall everything. The basemap import works fine on a normal terminal (from the exact same python path), but when submitted as a job via qsub it brings the following issue:

from mpl_toolkits.basemap import Basemap, addcyclic

Traceback (most recent call last):
  File "/var/spool/torque/mom_priv/jobs/63539.rdf-xcat.SC", line 21, in <module>
    from mpl_toolkits.basemap import Basemap, addcyclic
  File "/nerc/n02/n02/amethyst/miniconda3/envs/myenv/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 155, in <module>
    pyproj_datadir = os.environ['PROJ_LIB']
  File "/nerc/n02/n02/amethyst/miniconda3/envs/myenv/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'PROJ_LIB'
@WeatherGod
Copy link
Member

WeatherGod commented Oct 13, 2018 via email

@am-thyst
Copy link
Author

@WeatherGod thanks for this heads up, I just checked a qsub page and tried adding -V to my qsub command. The next error was different:

Traceback (most recent call last):
  File "/var/spool/torque/mom_priv/jobs/63543.rdf-xcat.SC", line 21, in <module>
    from mpl_toolkits.basemap import Basemap, addcyclic
  File "/nerc/n02/n02/amethyst/miniconda3/envs/myenv/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 156, in <module>
    epsgf = open(os.path.join(pyproj_datadir,'epsg'))
FileNotFoundError: [Errno 2] No such file or directory: 'PROJ_LIB/epsg'

@QuLogic
Copy link
Member

QuLogic commented Oct 13, 2018

I'm not sure that did what you thought it might. It's probably easier if in your command script, you activate the environment there instead of relying on qsub to pass along the right stuff.

@am-thyst
Copy link
Author

@QuLogic do you mean in the job script? I start it off with #!path/to/python/in/my/env, which seemed to work with my other environment

@QuLogic
Copy link
Member

QuLogic commented Oct 13, 2018

Yes, I don't think that is safe with how packages in conda-forge work. You really need to activate the environment to ensure that environment variables are set correctly. So it would be best if the job script were /bin/bash, activated the environment, and then ran the Python script you really wanted to run.

@WeatherGod
Copy link
Member

WeatherGod commented Oct 13, 2018 via email

@am-thyst
Copy link
Author

@QuLogic thanks for your suggestion, I've made some changes and I'm still getting the same key error. @WeatherGod surely I shouldn't have to delve into the basemap code? I've checked my version, I'm on basemap 1.2.0 with all requirements satisfied.

Tried the classic uninstall and reinstall, to no avail

@ImportanceOfBeingErnest
Copy link
Member

I had a similar problem when installing basemap into an existing conda environment via conda install -n myenv basemap=1.2 the other day. Unfortunately I can't remember if the missing environment variable was called PROJ_LIB or something else. I solved this by uninstalling basemap (but not the other dependencies it created), installing an old wheel file I had on disc for basemap 1.1, then installing basemap 1.2 on top of it.
Also I now cannot reproduce this with a fresh environment any more. Still, it might be interesting for you to know.

@am-thyst
Copy link
Author

@ImportanceOfBeingErnest thanks for the suggestion, installed basemap 1.1 instead and got the same error message. Weird.

@statiksof
Copy link

#419 Is not the same issue?

@am-thyst
Copy link
Author

@statiksof thanks for this - looks like I opened this in the wrong place, too. I'll close this and work through the other threads.

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

5 participants