Why is the derivative of $\ln |x|$ equal to $1/x$? In a complex analysis book, I read that $f(z) = 1/z$ doesn't have a primitive on $\mathbb{C}\setminus\{0\}$. 

The reason given used the much stronger fact that if any $g : \mathbb{C} \to \mathbb{C}$ is continuous and and has a primitive on an open set $\Omega \subset \mathbb{C}$, then the integral of $g$ along any closed curve $\gamma$ in $\Omega$ satisfies $$\int_{\gamma}^{} g(z) \,\,\mathrm{d}z = 0$$
Calculating the integral of $f$ along the unit circle gives $2\pi i$, which doesn't equal $0$, so $f$ doesn't have a primitive.

The antiderivative of $f(x) = 1/x$ on $\mathbb{R} \setminus \{0\}$ exists, and is $\ln |x|$. Why doesn't the complex equivalent of the natural logarithm work for $1/z$?
I realized while thinking about this that I don't even really know why the integral of $1/x$ is $\ln |x|$ ...
 A: The problem is that the complex logarithm is not a single-valued function. If you look for a solution to
$$ e^w = z $$
you will find that $ w \equiv \log z $ is only defined up to an additive $ 2\pi\mathrm{i} k $ (where $ k \in \mathbb Z $), as follows from Euler's identity
$$ e^{2\pi\mathrm{i}} = 1. $$
This implies that you must choose a particular value of $ k $ whenever you want to talk about a complex logarithm; any value for $ k $ defines a "sheet" in the so-called Riemann surface of the logarithm function. Let's say you pick a value of $ k $ once and for all; for instance, you may decide to take
$$ w = \log|z| + \mathrm{i}\mathrm{arg}{z}, $$ which is known as the principal branch of the logarithm (note that $ \log|z| $ is well-defined as $ |z| \in \mathbb R $).
You can satisfy yourself that this function is continuous on any simply connected open set of $ \mathbb C\backslash\{0\} $, but it fails to be continuous on $ \mathbb C \backslash \{0\} $ because any loop enclosing the origin must eventually cross the negative-$ x $ axis, where $ \arg{z} $ has a jump discontinuity. For this reason, that axis is called a branch cut for the function. While the particular location of the branch cut is due to the way we chose to define the function, there is no way to define a complex logarithm without branch cuts coming up somewhere.
This is the reason why $ z^{-1} $ doesn't have a primitive on any open set $ \Omega \subset \mathbb C $ such that $ 0 \in \Omega $, and also the reason why the contour integral of that function about the origin yields $ 2\pi\mathrm{i} N $, $ N $ being the number of times you've circled around the origin in the positive sense: this number is exactly the overall jump in $ \mathrm{arg}{z} $, corresponding to the fact you're scaling the logarithm's Riemann surface!
I hope this has at least given you an intuition of what's going on. I would advise you to read more about this topic on any introductory book, because it's probably the single most fascinating (if subtle) feature of complex analysis.
