简体   繁体   中英

Spyder default module import list

I'm trying to set up a slightly customised version of Spyder. When Spyder starts, it automatically imports a long list of modules, including things from matplotlib, numpy, scipy etc. Is there a way to add my own modules to that list?

In case it makes a difference, I'm using the Spyder configuration provided by the Python(X,Y) Windows installer.

First you have to create a Python file with the modules you want to import at startup. Suppose you call it my_imports.py and that it has this contents:

import numpy as np
import matplotlib.pyplot as plt

Then you have to go to

Tools > Preferences > IPython Console > Startup > Run a file

select the option

Use the following file

and finally click on the button to the right of text field below that option to select your my_imports.py file.

The startup script for Spyder is in site-packages/spyderlib/scientific_startup.py .

Carlos' answer would also work, but this is what I was looking for.

If Spyder is executed as a python script by python binary, then you should be able to simply edit Spyder python sources and include the modules you need. You should take a look into how is it actually executed upon start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM