Hi,
I dont know why, but i cant import a library that is in the same directory of my script.
Example:
my script is in StealthDir\Script
and the library is located in the same directory.
StealthDir\Script\testLib.py
StealthDir\Script\test.py
test.py:
import testLib
The Error:
ImportError: No module named testLib
I know it work, because a friend mine runs the same instruction and worked fine, seems to be a configuration problem on my pc.
anyone got this problem?
thanks
Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7
[Python] module
Re: [Python] module
i can't help - i dont use Py.
Python user invited in thread
Python user invited in thread
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Re: [Python] module
This is strange, maybe it is related to Python version.
With Python 3.x the import logic has been changed, try with
With Python 3.x the import logic has been changed, try with
Code: Select all
import .testLib.py #notice the dot before
Re: [Python] module
I`m using version 2.7.8.
Using windows 8.1 64bit, can be a problem too
Using windows 8.1 64bit, can be a problem too
Re: [Python] module
Then, long story short, you can (one of the following):
- add StealthDir\Script to your PYTHONPATH (search google on how to)
- add the following snippet at the very beginning of your test.py (before importing testLib)
Code: Select all
import os import sys sys.path.append(os.path.dirname(__file__)) import testLib #after you modified system.path
Re: [Python] module
The pythonpath tip worked fine...
Thanks a lot
Thanks a lot