# Getting started tutorial python problems

**URL:** <https://www.rubin.community/t/getting-started-tutorial-python-problems/9693>\
**Category:** Support\
**Tags:** python\
**Created:** [January 9, 2025, 9:55pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693 "2025-01-09T21:55:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 9, 2025, 9:55pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/1 "2025-01-09T21:55:37Z")

</div>

Hello,

I’m trying to run Getting started tutorial part 3: displaying exposures and source tables output by single frame processing. While running one of python commands I get error message : AttributeError: module ‘lsst’ has no attribute ‘obs’. What can be done about this and how to update lsst python packges?

Thank you

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 9, 2025, 10:09pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/2 "2025-01-09T22:09:29Z")

</div>

This implies that you’ve missed a call to `setup` somewhere since that is what will enable the python `lsst.x` packages. There should be a `setup lsst_distrib` somewhere. [Getting started tutorial part 1: setting up the Butler data repository — LSST Science Pipelines](https://pipelines.lsst.io/getting-started/data-setup.html#install-the-lsst-science-pipelines) links to [Setting up installed LSST Science Pipelines — LSST Science Pipelines](https://pipelines.lsst.io/install/setup.html)

I’m not sure how you got through step 2 without the python code set up.

---

<div class="post-metadata">

**Author:** ![sgreenstreet](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/sgreenstreet/32/1975_2.png) [@sgreenstreet](https://www.rubin.community/u/sgreenstreet)\
**Post date:** [January 10, 2025, 4:03pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/3 "2025-01-10T16:03:53Z")

</div>

Hi @VenIl - I just wanted to check whether running `setup lsst_distrib` as suggeseted by @timj fixed your issue?

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 5:25pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/4 "2025-01-10T17:25:07Z")

</div>

Hi @sgreenstreet , it still doesn’t work with same error message.

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 5:29pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/5 "2025-01-10T17:29:23Z")

</div>

## Here is the full error message if it helps:

AttributeError Traceback (most recent call last)  
File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/doImport.py:52, in doImport..tryImport(module, fromlist, previousError)  
51 try:  
—\> 52 pytype = getattr(pytype, f)  
53 except AttributeError as e:

AttributeError: module ‘lsst’ has no attribute ‘obs’

The above exception was the direct cause of the following exception:

ImportError Traceback (most recent call last)  
Cell In[3], line 2  
1 import os  
----\> 2 calexp = butler.get(‘calexp’, visit=23718, detector=41)

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/daf/butler/direct\_butler/\_direct\_butler.py:1177, in DirectButler.get(self, datasetRefOrType, dataId, parameters, collections, storageClass, timespan, \*\*kwargs)  
1168 \_LOG.debug(“Butler get: %s, dataId=%s, parameters=%s”, datasetRefOrType, dataId, parameters)  
1169 ref = self.\_findDatasetRef(  
1170 datasetRefOrType,  
1171 dataId,  
(…)  
1175 \*\*kwargs,  
1176 )  
 → 1177 return self.\_datastore.get(ref, parameters=parameters, storageClass=storageClass)

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/daf/butler/datastores/fileDatastore.py:2288, in FileDatastore.get(self, ref, parameters, storageClass)  
2285 if storageClass is not None:  
2286 ref = ref.overrideStorageClass(storageClass)  
 → 2288 allGetInfo = self.\_prepare\_for\_direct\_get(ref, parameters)  
2289 return get\_dataset\_as\_python\_object\_from\_get\_info(  
2290 allGetInfo, ref=ref, parameters=parameters, cache\_manager=self.cacheManager  
2291 )

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/daf/butler/datastores/fileDatastore.py:826, in FileDatastore.\_prepare\_for\_direct\_get(self, ref, parameters)  
823 if not fileLocations:  
824 raise FileNotFoundError(f"None of the component files for dataset {ref} exist.")  
 → 826 return generate\_datastore\_get\_information(  
827 fileLocations,  
828 readStorageClass=refStorageClass,  
829 ref=ref,  
830 parameters=parameters,  
831 )

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/daf/butler/datastores/file\_datastore/get.py:134, in generate\_datastore\_get\_information(fileLocations, ref, parameters, readStorageClass)  
131 if disassembled and storedFileInfo.component != refComponent:  
132 thisReadStorageClass = writeStorageClass  
 → 134 formatter = get\_instance\_of(  
135 storedFileInfo.formatter,  
136 FileDescriptor(  
137 location,  
138 readStorageClass=thisReadStorageClass,  
139 storageClass=writeStorageClass,  
140 parameters=parameters,  
141 component=storedFileInfo.component,  
142 ),  
143 dataId=ref.dataId,  
144 ref=ref,  
145 )  
147 formatterParams, notFormatterParams = formatter.segregate\_parameters()  
149 # Of the remaining parameters, extract the ones supported by  
150 # this StorageClass (for components not all will be handled)

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/introspection.py:153, in get\_instance\_of(typeOrName, \*args, \*\*kwargs)  
128 def get\_instance\_of(typeOrName: type | str, \*args: Any, \*\*kwargs: Any) → Any:  
129 “”“Given the type name or a type, instantiate an object of that type.  
130  
131 If a type name is given, an attempt will be made to import the type.  
(…)  
151 Raised if a module is imported rather than a type.  
152 “””  
 → 153 cls = get\_class\_of(typeOrName)  
154 return cls(\*args, \*\*kwargs)

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/introspection.py:120, in get\_class\_of(typeOrName)  
95 “”“Given the type name or a type, return the python type.  
96  
97 If a type name is given, an attempt will be made to import the type.  
(…)  
117 Raised if a module is imported rather than a type.  
118 “””  
119 if isinstance(typeOrName, str):  
 → 120 cls = doImportType(typeOrName)  
121 else:  
122 if isinstance(typeOrName, types.ModuleType):

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/doImport.py:114, in doImportType(importable)  
90 def doImportType(importable: str) → type:  
91 “”“Import a python type given an importable string and return it.  
92  
93 Parameters  
(…)  
112 item could not be retrieved from the imported module.  
113 “””  
 → 114 imported = doImport(importable)  
115 if isinstance(imported, types.ModuleType):  
116 raise TypeError(f"Import of {importable} returned a module and not a type.")

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/doImport.py:69, in doImport(importable)  
67 while moduleComponents:  
68 try:  
—\> 69 pytype = tryImport(“.”.join(moduleComponents), infileComponents, previousError)  
70 if not infileComponents and hasattr(pytype, moduleComponents[-1]):  
71 # This module has an attribute with the same name as the  
72 # module itself (like doImport.doImport, actually!).  
73 # If that attribute was lifted to the package, we should  
74 # return the attribute, not the module.  
75 try:

File ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/utils/doImport.py:55, in doImport..tryImport(module, fromlist, previousError)  
53 except AttributeError as e:  
54 extra = f"({previousError})" if previousError is not None else “”  
—\> 55 raise ImportError(  
56 f"Could not get attribute ‘{f}’ from ‘{module}’ when importing ‘{importable}’ {extra}"  
57 ) from e  
58 return pytype

ImportError: Could not get attribute ‘obs’ from ‘lsst’ when importing ‘lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter’ (No module named ‘lsst.obs’)

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 10, 2025, 5:47pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/6 "2025-01-10T17:47:32Z")

</div>

> [@VenIl](#):
>
> ~/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages/lsst/daf/butler/datastores/file\_datastore/get.py

How did you install the LSST science pipelines? This looks like a pip install of daf\_butler not the eups install.

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 5:53pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/7 "2025-01-10T17:53:55Z")

</div>

I Installed it with lsstsw and lsst-build.

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 6:10pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/8 "2025-01-10T18:10:49Z")

</div>

I have an Ubuntu laptop.

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 10, 2025, 6:37pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/9 "2025-01-10T18:37:49Z")

</div>

> [@VenIl](#):
>
> I Installed it with lsstsw and lsst-build.

Except somehow you have also managed to pip install the Rubin middleware packages. That does not happen when you run `rebuild lsst_distrib`. We expect most tutorial users to follow the installation instructions of installing with `lsstinstall` since `rebuild` will give you the cutting edge `main` version of every package.

What does `eups list lsst_distrib` report?

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 6:42pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/11 "2025-01-10T18:42:32Z")

</div>

output : gc7ba34d93f+8892a0c6f9 b7407 current setup

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 10, 2025, 6:48pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/12 "2025-01-10T18:48:11Z")

</div>

Ok. So lsst\_distrib is set up but the pip installed packages are somehow messing things up.

What about:

```auto
$ eups list obs_base
$ echo $OBS_BASE_DIR
$ ls $OBS_BASE_DIR/python

```

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 10, 2025, 8:05pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/13 "2025-01-10T20:05:30Z")

</div>

Oh, also please report your `$PYTHONPATH` value.

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 8:10pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/14 "2025-01-10T20:10:32Z")

</div>

g5c8c310e76+15eaa6c88b b7407 current setup  
/home/venil360/lsstsw/stack/lsst-scipipe-9.0.0/Linux64/obs\_base/g5c8c310e76+15eaa6c88b  
lsst

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 10, 2025, 8:16pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/15 "2025-01-10T20:16:40Z")

</div>

[’/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/eups/python’, ‘/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python311.zip’, ‘/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11’, ‘/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/lib-dynload’, ‘’, ‘/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages’]

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 10, 2025, 8:30pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/16 "2025-01-10T20:30:30Z")

</div>

That’s the problem. `setup lsst_distrib` didn’t set any of the PYTHONPATH environment variables. There is meant to be one var per eups package. I still can’t explain how you installed Rubin pip packages. To confirm you installed it as:

```auto
$ ./bin/deploy
$ . bin/envconfig
$ rebuild lsst_distrib
$ setup -t bNNNN lsst_distrib

```

and nothing else?

Can you start a new shell, source the bin/envconfig and try the setup again to see if you get the PYTHONPATH variable set properly?

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 11, 2025, 4:31pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/17 "2025-01-11T16:31:27Z")

</div>

Did what you told. I get : /home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/eups/python  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python311.zip  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/lib-dynload

/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 11, 2025, 4:33pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/18 "2025-01-11T16:33:12Z")

</div>

Did what you told. I get now : /home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/eups/python  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python311.zip  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11  
/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/lib-dynload

/home/venil360/lsstsw/miniconda/envs/lsst-scipipe-9.0.0/lib/python3.11/site-packages

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 13, 2025, 3:40pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/19 "2025-01-13T15:40:37Z")

</div>

That’s very confusing because somehow the `setup` call is not setting `PYTHONPATH` at all. This is seemingly impossible. Did you understand how you installed the middleware packages from PyPI? Does `rebuild lsst_distrib` work for you (since you are using `lsstsw`)?

Can you please try using `lsstinstall` as documented [here](https://pipelines.lsst.io/install/lsstinstall.html) ?

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [January 15, 2025, 9:23pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/20 "2025-01-15T21:23:35Z")

</div>

Given

> [@Getting started tutorial part 4 problems](http://www.rubin.community/t/getting-started-tutorial-part-4-problems/9715):
>
> Hello, I’m trying to run FGCM part of Getting started tutorial part 4 and getting error message:sst.daf.butler.cli.utils ERROR: Caught an exception, details are in traceback: Traceback (most recent call last): File "/home/venil/lsstsw/stack/lsst-scipipe-9.0.0/Linux64/daf\_butler/gc03a7ffb89+49d5bde2b1/python/lsst/daf/butler/\_butler\_config.py", line 138, in \_\_init\_\_ butlerConfig = Config(other) ^^^^^^^^^^^^^ File "/home/venil/lsstsw/stack/lsst-scipipe-9.0.0/Linux64/daf…

can I assume that you have resolved this topic?

---

<div class="post-metadata">

**Author:** ![VenIl](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@VenIl](https://www.rubin.community/u/VenIl)\
**Post date:** [January 15, 2025, 9:26pm UTC](https://www.rubin.community/t/getting-started-tutorial-python-problems/9693/21 "2025-01-15T21:26:12Z")

</div>

Yes, I reinstalled the whole system.  
Thank you.
