0

I have a python script named mesh_2.py

import sys
import os
import numpy as np
...

If I run it from Spyder with IPython console it works fine. But I want to run it with a cmd (start.cmd) file. It has the following content:

cmd /c activate py3.4 && mesh_2.py

As I try to run it I get:

ImportError: No module named numpy

I have Anadonda3 installed with a Python 3.4 environment named "py3.4". I am under Windows 7 64 bit.

If I open a cmd.exe myself and write:

activate py3.4
python
import numpy as np

Then everything is all right and I get no error messages. Does any of you have an idea what am I missing here?

Thank you in advance.

5
  • As I have written if I activate the environment manually then it does the import. So the package is installed in the virtual environment. Commented May 23, 2016 at 12:28
  • activate the virtual enviroment, then run your program like python mesh_2.py Commented May 23, 2016 at 12:30
  • The problem is that it needs to be started automatically. That is why I need the cmd script. Commented May 23, 2016 at 12:32
  • Maybe formatting the command correctly. cmd /c activate py3.4 && mesh_2.py. If using quotes they go around items with spaces. See cmd /? for help on quotes. The first one is in the wrong position, it was optional anyway.. Commented May 23, 2016 at 12:38
  • OK, you are right. I corrected it. But the error message is still the same. Commented May 23, 2016 at 12:42

1 Answer 1

2

try replacing

cmd "/c activate py3.4 && mesh_2.py"

with

cmd "/c activate py3.4 && python mesh_2.py"
Sign up to request clarification or add additional context in comments.

1 Comment

No worries. Got me once or twice too

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.