Python uses PYTHONPATH environment variable to define a list of folders which should be looked at when importing modules. Most likely your folder is not PYTHONPATH
Answer from Kozyarchuk on Stack OverflowPython Module Importing Problems
Import issues in Python - Stack Overflow
Python importing issue I'm having - Stack Overflow
python import problem - Stack Overflow
is main/src in sys.path? Python resolves module names by searching the directories in sys.path. For example "import ../module.py" is not valid. To fix your problem do something like this: In your "main/tests/test.py" file add:
import sys, os
sys.path.insert(0, os.path.abspath("../src") )
# Then try
from domain.entries import MyClass
You will also need to make sure that main/src/domain contains an init.py file. Also you don't need init.py in main/tests unless your going to add it's parent directory to your path and import tests.something.
Hope this helps.
You need __ini__.py in every directory within the package
main/__init__.py
main/src/__init__.py
main/src/domain/__init__.py
main/src/domain/entities.py
main/tests/__init__.py
You shoud not add the project directory to your pythonpath but it's parent, e.g. imagine the setup
/home/user/develop/project/src/model
You'd add /home/user/develop to PYTHONPATH
If that still doesn't work, make sure you don't have a 'project.py' insite project/src/model.
Make sure you have the parent directory of project/ on your pythonpath, rather than the project directory. If you add the project path itself, imports like import project.src will look for project/project/src.
On windows, Python looks up modules from the Lib folder in the default python path, for example from "C:\Python34\Lib\". You can add your Python libaries in a custom folder ("my-lib" or sth.) in there, but you need a file in order to tell Python that you can import from there. This file is called __init__.py , and is totally empty. That data structure should look like this:
my-lib
(This is how every Python module works. For example urllib.request, it's at "%PYTHONPATH%\Lib\urllib\request.py")
You can import from the "mymodule.py" file by typing
import my-lib
and then using
mylib.mymodule.myfunction
or you can use
from my-lib import mymodule
And then just using the name of you function.
You can now use sys.path.append to append the path you pass into the function to the folders Python looks for the modules (Please note that thats not permanent). If the path of your modules should be static, you should consider putting these in the Lib folder. If that path is relative to your file you could look for the path of the file you execute from, and then append the sys.path relative to your file, but i reccomend using relative imports.
If you consider doing that, i recommend reading the docs, you can do that here: https://docs.python.org/3/reference/import.html#submodules
If I got you right, you're using Python 3.3 from Blender but try to include the 3.2 standard library. This is bound to give you a flurry of issues, you should not do that. Find another way. It's likely that Blender offers a way to use the 3.3 standard library (and that's 99% compatible with 3.2). Pure-Python third party library can, of course, be included by fiddling with sys.path.
The specific issue you're seeing now is likely caused by the version difference. As people have pointed out in the comments, Python 3.3 doesn't find the _tkinter extension module. Although it is present (as it works from Python 3.2), it is most likely in a .so file with an ABI tag that is incompatible with Blender's Python 3.3, hence it won't even look at it (much like a module.txt is not considered for import module). This is a good thing. Extension modules are highly version-specific, slight ABI mismatches (such as between 3.2 and 3.3, or two 3.3 compiled with different options) can cause pretty much any kind of error, from crashes to memory leaks to silent data corruption or even something completely different.
You can verify whether this is the case via import _tkinter; print(_tkinter.file) in the 3.2 shell. Alternatively, _tkinter may live in a different directory entirely. Adding that directory won't actually fix the real issue outlined above.