[SYS + OS] Script not Imported, Error Found ! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [SYS + OS] Script not Imported, Error Found ! (/thread-5215.html) |
[SYS + OS] Script not Imported, Error Found ! - JamieVanCadsand - Sep-22-2017 Hey Python Programmers... I Try to train my self in working with SYS and OS. In this case... create an simple program they get more python scripts loading. But now... this is an simple test. My first script you must start with: import os import sys import jamics module = "../script/module/jamics" script = sys.path.append(os.path.abspath(module)) print("Script Map: ", script)This give the bigest problem. This script must be load my other module script jamics, but it doesn't. I get just an error. Python said thad jamics is not cognized. So... this is my other script for my test with os and sys. My seccond script they must be importing from my first script: print("Jamics Imported !...")Can anyone see whats wrong with my script ?... i don't can see the problem. They are two test scripts to test my knowledge for import files with os and sys. This is an simple test. Can anyone help me to tell what the problem is ?... Thanks, Jamie. RE: [SYS + OS] Script not Imported, Error Found ! - ichabod801 - Sep-22-2017 You need to do the import after changing sys.path. Also, you should be able to set your system to check that folder automatically by setting the PYTHONPATH environment variable. How you do that depends on your operating system. Using PYTHONPATH is the preferred method. RE: [SYS + OS] Script not Imported, Error Found ! - snippsat - Sep-22-2017 If scripts are in same folder or in jamics.py in PYTHONPATH. C:\foo\ |-- jamics.py |-- run.py # jamics.py def jam(): return ("Jamics Imported !...") # run.py import jamics # using module jamics print(jamics.jam())Test: Placing jamics.py in a place Python do not search(sys.path).import sys # Before import jamics sys.path.append('C:/somefolder/anotherfolder') import jamics # using module jamics print(jamics.jam()) |