2019-03-14 01:52:37

So, if I want to use libraries that are not installed via pip installer, I have to include these lines into my scripts:

import sys, os
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path)

I should probably mention that I do this to run my scripts:
1: open run dialog, type cmd.
2: type in cd c:\python directory
3: Pasting my script path and hitting enter.
So yeah, any way to illiminate the lines pasted above from my scripts?

Coding is not hard. No, not at all.
What is hard is dynamic coding, coding that accepts different input at different times.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

2019-03-14 02:50:27

Just put all the .py files in the same folder as your scripts .py file.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2019-03-14 03:13:19

Right, I can do that, but then comes in the problem of dlls. The scripts just refuse to find the dlls without me including the lines in the first post.

Coding is not hard. No, not at all.
What is hard is dynamic coding, coding that accepts different input at different times.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

2019-03-14 07:25:15

Uh... which modules are opening DLLs?

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2019-03-16 18:26:46

Any module: Tolk has a Tolk.py and a dll associated with it. It can't find the DLL unless I set the working directory to my script. Any way to do it automatically and without those lines?

Coding is not hard. No, not at all.
What is hard is dynamic coding, coding that accepts different input at different times.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

2019-03-16 23:58:22

Tolk has some serious trouble with its dll. Usually tolk should provide several solutions to searching for its dll or selecting them during runtime or some other way. You are right, it is just possible to add the path to the overall system paths within python to fix this. However, its not best practice to run any script from within the python directory, but from within the script directory instead. Whats so hard about opening a cmd from within the script folder (Windows 10 even has menu items within the start menu when pressing alt I believe) and just write

python my_script.py

from within the cmd afterwards? That would solve all your problems. You could also create shortcuts on your desktop which run the corresponding python command to start your script. The advantage of shortcuts is that you can manually select the working directory the script should be run in.
Best Regards.
Hijacker

Thumbs up

2019-03-17 01:12:45

@post 6, It's not difficult... if you know about it. I didn't. thanks for the enlightenment.

Coding is not hard. No, not at all.
What is hard is dynamic coding, coding that accepts different input at different times.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up