Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case sensitive issue on Windows #3309

Closed
Grazfather opened this issue Dec 18, 2015 · 14 comments
Closed

Case sensitive issue on Windows #3309

Grazfather opened this issue Dec 18, 2015 · 14 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@Grazfather
Copy link

pip install crypto -> Creates lowercase crypto in site-packages
pip install pycrypto -> Installs pycrypto to 'Crypto', but because the fs on windows is case-insensitive, it installs to the already existing crypto.
python -m Crypto -> ImportError: No module named Crypto

see pycrypto/pycrypto#156

@pfmoore
Copy link
Member

pfmoore commented Dec 18, 2015

So crypto and pycrypto both claim the name "crypto" for imports (with one claiming it in lowercase, and the other with an initial capital)? This is a bug (or incompatibility) in those packages, as they are using the same name.

PyPI only mandates uniqueness of distribution names, not of the import names used by distributions. But one or the other package should probably change. From the project upload dates, pycrypto is the older package, but using an import name that doesn't match the project name means that it's not exactly the crypto project's fault that they didn't know the name crypto was in use.

@Grazfather
Copy link
Author

Sure, but I figure the issue here is that pip doesn't correctly rename the dir it's installing to. I think that (trashing the old install) is actually saner behaviour than silently installing to a dir with a name in different case.

Although contrived, i think by demonstrating that creating a dir 'crypto' and then installing PyCrypto, and it succeeding shows why I consider this a bug in pip itself, only made apparent because of the package collision.

@pfmoore
Copy link
Member

pfmoore commented Dec 19, 2015

Ah, I see your point. Personally, I'm inclined to treat it as a case of "don't do that" rather than being something it's worth working round in pip, but if someone were to feel strongly enough to create and merge a fix, I wouldn't object.

@xavfernandez
Copy link
Member

I'd also go on the "don't do that" side:

  • non-wheel installations are not performed by pip but by setuptools
  • some packages are namespaced and legitimately install files in the same directory

@Grazfather
Copy link
Author

Then could the bug be that python is case sensitive, but pip/wheel/setuptools is not? Not sure how you'd work around this on osx/windows, though, so it makes sense that it's a 'don't do this' kind of thing, but how do we warn others?

@xavfernandez
Copy link
Member

Well this is not a case sensitivity issue: different packages can legitimately install in the same directory like PIL and pillow which both install in PIL directory.

And in the case of namespaced package, it is expected that several packages will write in the same directory so I don't think there is a better solution than Do not do this.

@Grazfather
Copy link
Author

if os.path.isdir(path) and os.path.basename(path) != os.path.basename(path.lower()):
    ...

or similar could test, at the time of installation, whether there's going to be a failure. There's no real way to prevent this issue, but I think it's better to warn than to fail silently.

The issue isn't collisions -- That's expected. The issue, imo, is that pip installs without complaint or warning.

Easy repro steps:

~/tmp 09:09:46$ python -m virtualenv delme
New python executable in delme/bin/python
Installing setuptools, pip, wheel...done.
~/tmp 09:09:58$ . delme/bin/activate
(delme)~/tmp 09:10:14$ pip install crypto
Collecting crypto
  Downloading crypto-1.4.1-py2.py3-none-any.whl
Collecting Naked (from crypto)
  Downloading Naked-0.1.31-py2.py3-none-any.whl (590kB)
    100% |████████████████████████████████| 593kB 782kB/s
Collecting shellescape (from crypto)
  Downloading shellescape-3.4.1-py2.py3-none-any.whl
Collecting requests (from Naked->crypto)
  Downloading requests-2.9.1-py2.py3-none-any.whl (501kB)
    100% |████████████████████████████████| 503kB 1.0MB/s
Collecting pyyaml (from Naked->crypto)
Installing collected packages: requests, pyyaml, Naked, shellescape, crypto
Successfully installed Naked-0.1.31 crypto-1.4.1 pyyaml-3.11 requests-2.9.1 shellescape-3.4.1
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(delme)~/tmp 09:10:21$ ls delme/lib/python2.7/site-packages/
Naked                           _markerlib                      crypto-1.4.1.dist-info          pip                             requests                        setuptools-18.2.dist-info       wheel
Naked-0.1.31.dist-info          _yaml.so                        easy_install.py                 pip-7.1.2.dist-info             requests-2.9.1.dist-info        shellescape                     wheel-0.24.0.dist-info
PyYAML-3.11.dist-info           crypto                          easy_install.pyc                pkg_resources                   setuptools                      shellescape-3.4.1.dist-info     yaml
(delme)~/tmp 09:10:43$ pip install pycrypto
Collecting pycrypto
Installing collected packages: pycrypto
Successfully installed pycrypto-2.6.1
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(delme)~/tmp 09:10:48$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Cipher import AES
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Crypto.Cipher
>>> from crypto.Cipher import AES
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/grazfather/tmp/delme/lib/python2.7/site-packages/crypto/Cipher/AES.py", line 49, in <module>
    from Crypto.Cipher import blockalgo
ImportError: No module named Crypto.Cipher

@xavfernandez
Copy link
Member

But there are a lot of cases where there is no reason to warn if two packages install themselves in the same directory. Cf all the zope.* (zope.interface, zope.event, etc) that install themselves in the zope directory.

One thing that could maybe be done, would be to load all the installed files in the environment (from RECORD/SOURCES.txt files and check if the installation is overriding some files. But this might be slow in environments with lots of installed packages/files.

@Grazfather
Copy link
Author

I think you're missing the point. I don't think that they should check that they install to the same dir, i think they should check that if the target directory exists, but its case is different, then warn that it WILL break.

@xavfernandez
Copy link
Member

I did miss your point and now, just like pfmoore:

I'm inclined to treat it as a case of "don't do that" rather than being something it's worth working round in pip, but if someone were to feel strongly enough to create and merge a fix, I wouldn't object.

Note that depending on the fix, it might also have to go in setuptools.

@Grazfather
Copy link
Author

Great. I will look into it, but unfortunately both projects are unfamiliar to me.

@nvkgrandhi
Copy link

HI all,

I am also facing same issue. If you found the solution that will be great help. And let me also know the solution.

I have a workaround for this issue.

So what i have done is.
After installing paramiko
it is showing error as below
ImportError: No module named Crypto.Cipher

so i have installed Crypto using PIP and then also i got same issue.

I just renamed the crypto folder to Crypto as below

go to -> C:\Python34\Lib\site-packages
look for 'crypto' folder and rename to 'Crypto' that's all!!!

Then its started working as expected........ :) hope this will help you.

@dstufft
Copy link
Member

dstufft commented Mar 24, 2017

Closing this. You can't install two distributions with the same name, and on a case insensitive FS that extends to the name of the python packages as well.

@dstufft dstufft closed this as completed Mar 24, 2017
@Grazfather
Copy link
Author

Sure it's not supported, but pip could do a lot better at handling it or warning. At least this'll show up on google.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

5 participants