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?

2
  • 1
    Just to make sure I'm not missing the point here: When you say PythonGUI, are you talking about the Python IDLE? Or some other GUI? Commented Sep 1, 2014 at 17:48
  • @mattingly890 Yes, The same Python IDLE is the point :) Commented Sep 1, 2014 at 17:52

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.