Let $\pi:X\rightarrow Y$ be a smooth proper (assume projective if needed) morphism of schemes with $Y$ locally noetherian, and let $Z\subset X$ be an irreducible integral closed subscheme containing no fiber of $\pi$.


* Is the locus $Pic\_\pi(Z)=\{y\in Y:Z\_y \text{ is Cartier in }X\_y\}$ closed in $Y$?
* If not, what extra hypotheses would make it closed?


As $\pi$ is smooth, Cartier and Weil divisors on fibers are the same, and as it is proper, the dimension of fibers is semicontinuous, so the issue is actually about components of smaller dimension in the fibers. Thus I'd drop the hypothesis on not containing fibers and replace it by the hypotheses that $Z$ dominates $Y$; then the question would be:


* Is the locus of $y$ such that $Z\_y$ has a (possibly embedded) component of codimension $\ge 2$ in $X\_y$ open in $Y$?


I have the feeling that this is related to Zariski's main theorem, although in the first formulation it seems closer to asking whether the subscheme of relative effective divisors is closed in the Hilbert scheme when $\pi$ is smooth. But I can't pin it down.


(In my situation, $Z$ is actually of codimension 2, and everything is over the complex field, but I don't think this is necessary).



Irreducible "family" of relative effective divisors of a smooth morphism
In fact both sets are constructible in $Y$. 


Suppose for simplicity that $X$ is connected. Then the dimension of the (non-empty) fibers of $X\to Y$ is constant (EGA IV.12.1.1(i), and flatness is enough), denote it by $d$. Let $Y'$ be the (integral) image of $Z$ in $Y$. We can replace $X\to Y$ by $X\times\_Y Y'\to Y'$ and suppose that $Z\to Y$ is surjective. Let $e$ be the dimension of the generic fiber of $Z\to Y$. 


**Special case: $e=d-1$.** By Chevalley's theorem (EGA IV.13.1.1), for any $y\in Y$, the irreducible components of $Z\_y$ all have dimension $\ge d-1$. By hypothesis, $Z\_y\ne X\_y$, hence $\dim Z\_y\le d-1$. 
Therefore $ \mathrm{Pic}\_\pi(Z) = Y $ (and it is closed in $Y$ if $Z$ doesn't dominate $Y$). 


**General case.** The set of $x\in Z$ such that $\dim\_x Z\_{\pi(x)}\le d-2$ is open in $Z$ (EGA IV.13.1.3). The complementary of the image by $\pi$ of this open subset is constructible and is your 
${Pic}\_{\pi}(Z)$. 


In case $Z\to Y$ is flat, then $\mathrm{Pic}\_\pi(Z)$ is closed by openess of $\pi|\_Z$.


For the second question, if $F$ denotes the set of $x\in Z$ such that all associated components of $Z\_{\pi(x)}$ passing through $x$ have dimension $\ge d-1$, then you are considering $\pi(X\setminus F)$. By EGA, IV.9.9.2(iii), $F$ is constructible, so your set is constructible. 


If $Z\to Y$ is moreover flat, then $F$ is open by EGA, IV.12.1.1(i) (I learn recently this reference from an anonymous referee.), hence your set $\pi(X\setminus F)$ is in fact closed.


