Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.25k stars 414 forks source link

Having issues getting past the "_version.py" whenever I attempt to import #1493

Closed WxReese closed 3 years ago

WxReese commented 4 years ago

I am running into issues whenever I attempt to run any kind of code from metpy.

All of this code works:

import numpy as np
from metpy.units import units

length = 10.4 * units.inches
width = 20 * units.meters

print(length, width)

area = length * width

print(area)

print(area.to('m^2'))

print(10* units.degC - 5 * units.degC)

print(25 * units.degC + 5 * units.delta_degF)

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import pandas as pd

However, whenever I attempt to add this kind of code:

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import Hodograph, SkewT

I get this error:

Traceback (most recent call last):

  File "C:\Users\*\Anaconda3\lib\site-packages\metpy\_version.py", line 15, in get_version
    return get_version(root='..', relative_to=__file__,

  File "C:\Users\*\Anaconda3\lib\site-packages\setuptools_scm\__init__.py", line 144, in get_version
    return _get_version(config)

  File "C:\Users\*\Anaconda3\lib\site-packages\setuptools_scm\__init__.py", line 148, in _get_version
    parsed_version = _do_parse(config)

  File "C:\Users\*\Anaconda3\lib\site-packages\setuptools_scm\__init__.py", line 110, in _do_parse
    raise LookupError(

LookupError: setuptools-scm was unable to detect version for 'C:\\Users\\*\\Anaconda3\\lib\\site-packages'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Users\*\Anaconda3\lib\site-packages\setuptools_scm\untitled2.py", line 33, in <module>
    from metpy.plots import Hodograph, SkewT

  File "C:\Users\*\Anaconda3\lib\site-packages\metpy\__init__.py", line 36, in <module>
    __version__ = get_version()

  File "C:\Users\*\Anaconda3\lib\site-packages\metpy\_version.py", line 19, in get_version
    return get_distribution(__package__).version

  File "C:\Users\*\Anaconda3\lib\site-packages\pkg_resources\__init__.py", line 480, in get_distribution
    dist = get_provider(dist)

  File "C:\Users\*\Anaconda3\lib\site-packages\pkg_resources\__init__.py", line 356, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]

  File "C:\Users\*\Anaconda3\lib\site-packages\pkg_resources\__init__.py", line 899, in require
    needed = self.resolve(parse_requirements(requirements))

  File "C:\Users\*\Anaconda3\lib\site-packages\pkg_resources\__init__.py", line 785, in resolve
    raise DistributionNotFound(req, requirers)

DistributionNotFound: The 'appdirs' distribution was not found and is required by pooch

I did comment each of the three things out and got the same error every time. I'm not sure where to go from here.

I am on Windows and just downloaded Anaconda & Metpy today. Windows 10 v64

dopplershift commented 4 years ago

Did you install metpy using conda? or pip? Since you're using Anaconda, it will be easiest to install using conda: conda install -c conda-forge metpy

It also looks like you're running a script untitled2.py from the C:\Users\*\Anaconda3\lib\site-packages\setuptools_scm\ directory. Can you try moving that file somewhere else outside your python install (maybe your Documents folder) and trying again? Trying to run from a directory within your Python install can yield weird results.

dopplershift commented 3 years ago

It doesn't sound like there's anything for us to do here. If there is, feel free to re-open and supply us with the info requested above. Thanks!