-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
"import file mismatch" error (__pycache__) when project directory is accessible via symlinks #3607
Comments
GitMate.io thinks possibly related issues are #774 ("import file mismatch" with git), #2078 (Error when --confcutdir is not a directory), #702 ("import file mismatch" despite different names (only Windows 7?)), #200 (disable the creation of the pycache directory), and #223 (pytest fails collecting on py25 with "import file mismatch" - HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules). |
Have the same problem when running tests in docker |
Should we close this as duplicate? |
Dunno, my issue does involve symlinks |
Not a symlink issuer per-se, but Docker allows you to mount your source-code into a container as a volume- meaning that if you run pytest inside a container the pycache files point to a path that does not exist on the host (meaning that you cannot run pytest from the host without cleaning up the output files) |
Yes, I added that to my Makefile to workaround the issue, just figured I would add the comment for anyone else who was seeing the same problem. Thanks! |
@jimbo1qaz can you confirm if deleting the |
Yes, that's how I worked around it (though it was rather annoying to manually perform that whenever switching between IDE and CLI tests). |
Thanks for reporting back. 👍 I'm closing this because this (long standing) issue is already tracked by #2042. |
In my case I just needed to read the error a little more -- my
I had to change it so that the sub test modules weren't the same as such
I didn't have to have those exact naming scheme, I only needed to make sure that my test module files were named uniquely. |
in my case with Docker, it was the since i run tests before dockerizing. removing |
Fixed same issue by adding |
Side note on the 'docker' occurrence of that problem: I fixed it by adding the following two lines in
|
Python |
thanks |
For cloud sync reasons, I symlinked C:\Users\nyanpasu64\encrypted as an alias for nyanpasu64\Dropbox\encrypted (the actual folder).
I have a virtualenv under
C:\Users\nyanpasu64\[Dropbox\]encrypted\code\amk_tools\venv
.C:\Users\nyanpasu64\encrypted\code\amk_tools\venv\Scripts
(symlink) is present in PATH.I have a setup.cfg file under code\amk_tools, containing
I'm using both PyCharm test runner, and the integrated terminal, to run tests.
When I run
pytest
from cmd in pwd=C:\Users\nyanpasu64\Dropbox\encrypted\code\amk_tools
, it works fine. When I runpytest
from cmd in pwd=C:\Users\nyanpasu64\encrypted\code\amk_tools
, I get the following error:and one such error per test_*.py file.
Removing all
__pycache__
files and runningpytest
from encrypted, it works and now Dropbox\encrypted\ has the error.pip list:
pytest (3.6.2) on Windows 10 x64 with developer mode and symlinks enabled
The text was updated successfully, but these errors were encountered: