Getting cx_Oracle with correct case using conda
<p>I'm new to Python. I'm using the Anaconda 4.1.1 (Python 3.5.2) distribution on Ubuntu. I started working on a project that uses <a href="http://cx-oracle.sourceforge.net/" rel="nofollow"><code>cx_Oracle</code></a>. O could of course install <code>cx_Oracle</code> using <code>pip</code>.</p>

<pre><code>pip install cx_Oracle
</code></pre>

<p>But everyone seems to be saying that Anaconda's <code>conda</code> is a much better package manager, virtual environment manager, and dependency manager that <code>pip</code> and <code>virtualenv</code> put together. I'd prefer to just use <code>conda</code> for managing everything.</p>

<p>So I made a <code>requirements.txt</code> file (some of my teammates will still be using <code>pip</code> and <code>virtualenv</code>) with the following line. (I want to support Python 3.5, so I need <code>cx_Oracle</code> 5.2.1, the current latest.)</p>

<pre><code>cx_Oracle==5.2.1
</code></pre>

<p>Then I tell <code>conda</code> to create a virtual environment <code>foobar</code>:</p>

<pre><code>conda create -n foobar --file requirements.txt
</code></pre>

<p>This fails; unfortunately <code>cx_Oracle</code> 5.2.1 is not yet in the Continuum conda repository (even though half the year has passed since it was released). However there are several channels (e.g. <code>mgckind</code>) purporting to supply version 5.2.1. There's just one problem: all the channels are supplying <code>cx_oracle</code> and not <code>cx_Oracle</code> (note the case difference). So this won't work:</p>

<pre><code>conda create -n foobar -c mgckind --file requirements.txt
</code></pre>

<p>Even if I specify a channel as in the example above, and even though <code>requirements.txt</code> clearly says <code>cx_Oracle</code>, <code>conda</code> brings down <code>cx_oracle</code> with a lowercase <code>o</code>. Because Python module imports are apparently case sensitive, all my tests fail because they can't find <code>cx_Oracle</code> with an uppercase <code>O</code>.</p>

<p>Am I missing something simple here because I'm new to Python? Or is Anaconda really both behind the times and incompatible with <code>cx_Oracle</code>, meaning I'll have to use <code>pip install</code> and bring it down from PyPI?</p>

<p>If there is really a case difference, is this situation common on Conda vs PiPY? Is it a Conda policy to name things only in lowercase? How do others deal with the discrepancy?</p>

<p>The problem had nothing to do with the lowercase package name on Continuum's conda repository. In fact I was missing something. I had created a new virtual environment as I mentioned in the question:</p>

<pre><code>conda create -n foobar --file requirements.txt
</code></pre>

<p>The requirements file contained <code>cx_Oracle==5.2.1</code>, which I also mentioned. But what I did <em>not</em> mention is that I then tested the program using <code>nosetests</code>, and the <code>requirements.txt</code> file did <em>not</em> include <code>nose</code>! This means that the unit tests were being run by the default Anaconda installation of <code>nose</code>, which had no knowledge of <code>cx_Oracle</code>, which was not installed into the main Anaconda installation. (The virtual environment, because of dependency issues, had pulled down Python 3.4, while the Anaconda installation was using Python 3.5.)</p>

<p>In any case, the issue was that I inadvertently was using <code>nose</code> from the default installation of Anaconda, not from my virtual environment. The <code>cx_oracle</code> installed into my virtual environment, as kalefranz pointed out, will requires <code>import cx_Oracle</code> regardless of the case of its package name.</p>

<p>As soon as I installed <code>nose</code> into my virtual environment, running <code>nosetests</code> worked because it picked up the <code>cx_oracle</code> installation.</p>

<p>In summary the following seems to be the package/module case situation in the Python world:</p>

<ul>
<li>Python module imports are case-sensitive.</li>
<li>Package names are case-insensitive.</li>
<li>The new best-practices approach is to use all lowercase in package names.</li>
<li>The PyPI repository retains case; the Continuum conda repository converts package names to lowercase.</li>
<li>Regardless of whether one pulls a package from PyPI or Continuum conda, and regardless of which package case is used to retrieve them, the module name and its corresponding import statement in the code should retain the official case used by the library.</li>
</ul>

python pip anaconda cx-oracle conda