Issue
I am facing a really unexpected error and I am wondering if anybody else has had that before.
The setup I am using is the following: macOS 10.14.6 with Python 3.7 I am also using ipython and spyder, but its unrelated to my problem as it happens in the normal python shell, as well.
I have a module called FLAP and several submodules which all rely on the main FLAP module. They are in the same directory called git-repos. I added git-repos to the PYTHONPATH in spyder (or to sys.path in python shell). If I only have the spyder's ipython shell or just a python shell opened, I can import my own modules.
As soon as I open the git-repos folder with e.g. Commander One, python cannot import the modules. I also tried using the Sourcetree git client, that induced the same thing. If I exit the folder in the Commander One app, then it can be imported again after restarting the python shell.
Furthermore, I find it strange that it doesn't happen with macOS's Finder and also doesn't happen with installed packages like matplotlib or numpy.
I think it is also important to mention, that the whole directory is in a Google Drive Filestream mounted into /Volumes.
Have you guys ever seen this kind of problem before?
Solution
It turned out that you cannot do the following in macOS:
- Have your module directory in a Google Drive File Stream and
- Have that directory in the PYTHONPATH and
- Open the same directory in e.g. Commander One and
- Be able to import the module in python
You can do 3. OR 4. but not 3. AND 4. If condition one is not true then you can import the module no matter what.
This is a bug in the macOS Google Drive software. The folder seems to be locked down when it is opened in another app (not Finder) and thus the python shell cannot find it.
At the end I moved the folder from the Google Drive onto my drive and I can import it no matter what. I fired up a crontab record so it would backup my codes regularly to the drive.
I spent three days on trying to find the source of the error. I think this could help other people who face this very specific issue.
Answered By - Máté Lampert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.