2

I want to work with smartcard readers. So I must import some modules such as core from pycard library.

Q1: How I can do it automatically! Now each time I open PythonGUI I must import it again and again!

Q2: How I can add a path to sys.path permanently?

TheGoodUser
  • 1,188
  • 4
  • 26
  • 52

1 Answers1

3

Part 1:

From the Python Docs:

Upon startup with the -s option, IDLE will execute the file referenced by the environment variables IDLESTARTUP or PYTHONSTARTUP. IDLE first checks for IDLESTARTUP; if IDLESTARTUP is present the file referenced is run.

IDLESTARTUP is an environment variable that tells the IDLE the location of a python script to execute on startup, as long as the -s option is given when you start the IDLE. Thus you need to edit the script pointed to by IDLESTARTUP or PYTHONSTARTUP, add the import ... statement, and use the -s flag to start the IDLE.

Part 2:

To add to the sys.path permanently, you can edit the same file we edited above (the file referred to by IDLESTARTUP or PYTHONSTARTUP, and do a

import sys
sys.path.append("...")

Note on Environment Variables:

To figure out if you have a IDLESTARTUP variable or PYTHONSTARTUP variable defined in Windows, you should be able to go to Control Panel > System and Security > System > advanced > Environment Variables.*

*(I'm not much of a Windows user, so you might need to seek out how to change environment variables in Windows on other questions or Google).

therealrootuser
  • 10,215
  • 7
  • 31
  • 46