简体   繁体   中英

Python run file from command line

Yesterday I installed Python (with Numpy & Scipy) on CentOS, everthing works fine when I'm using the CLI and do some math. But now I try to execute a file, and then a weird error appears, searched all over the place but can't find the solution to fix this.

I'm running two Python versions, the version I'm using is 3.4, and I installed it at: /usr/local/bin

Then I made a file called test.py in the same directory, with this code:

import numpy    

When I try to run it with:

./python3.4 -m test.py    

I get this error:

/usr/local/bin/python3.4: Error while finding spec for 'test.py' (<class 'AttributeError'>: 'module' object has no attribute '__path__')   

I hope somebody can lead me into the right direction, thanks in advance!

Running things like

 python -m <something>

invokes Python, which then tries to import a Python Module.

From your short example it doesn't appear to be a valid Python module

Try running with python <your python code file> instead.

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