7

Note: I'm new to Python and I've never really used external modules like the ones listed below so feel free to let me know if there's anything I could be doing better in order to get my program up and running.

I'm currently working with a python (2.7.x) program that requires the use of the SciPy stack. The previous developer of the program was using Anaconda in order to access all external modules. In my case, I need to be able to run the entire program with a single command. For example:

python myFile.py

Will execute myFile.py (which has the following imports):

from numpy import *
from pylab import *
import matplotlib.pyplot as plt

From what I understand, Anaconda is an IDE that requires you to execute code in a similar way to Visual Studios (i.e. a "Run" button). So my question is:

Is there a way for me to do this directly from the command line?

Note: The reason I'm specifying the use of Anaconda instead of just using the external modules themselves is because on the SciPy website there's constant mention that it's easiest to just use a scientific python distribution like Anaconda or Python(x,y). Ultimately, I'm okay with any solution that allows me to run my program with the above imports.

  • 1
    Not really, anaconda tries to make a Python that is independent of the Python installed on the OS. It uses the conda command to manage environments, e.g. conda env list. The environments are not that different from virtualenv and use a script called activate that need to be sourced, e.g. source activate <env>. But my experience with anaconda is pretty limited so I may be wrong about some parts. – grochmal Aug 3 '16 at 20:32
  • just type the name of the program you want to run. e.g if you are inside the required environment and want to run program called spades. type spades and give the file directory and output name etc – user355034 May 27 at 20:37
5
  1. Create required Anaconda environment conda create --name environmentName python=3 pandas numpy.

    Include all your dependencies at once while creating the environment.

  2. Run the environment source activate environmentName.
  3. Executing the python script python fileName.py. You don't have to specify the python version because the script is running inside the Anaconda environment. The version used will be whatever is specified in the environment (the script required python3 which has already been specified in Anaconda environment).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.