1

I want to run a locally stored .py program in the CMD line of windows because it is the only way I can call the programs from other programing enviroment.

When trying to do so I specify in the CMD line the location of python.exe (anaconda folders) and the location of the python program.

The problem is that whereas the programs work well when run in the anaconda environement (jupyter started from anaconda) they are missing the libraries installed in anaconda (the ones not included in the basic library, pandas numpy).

I find in here exactly this same problem but trying to implement the solution proposed does not solve the problem in my case.

Situation: Python 3.7 installed in Windows machine with anaconda. Pandas and numpy present in the list of installed packages in the anaconda navigator. Pandas imported with no problem into the jupyter notebook with no problem.

Program writen in Jupyter notebook started from anaconda navigator.

Download .py file in a particular location of the hard disc.

Open CMD terminal and run

C:\Users\xxxxxx>C:\Users\xxxxxx\AppData\Local\Continuum\anaconda3\python.exe C:\Users\xxxxxx\pyCODE\pySoft.py 

Traceback (most recent call last):

 File "C:\Users\xxxxxx\pyCODE\pySoft.py", line 30, in <module> import pandas as pd

 ModuleNotFoundError: No module named 'pandas'

Following instructions in the above mentioned link I unstalled pandas and numpy in the anaconda prompt line

(base) C:\Users\xxxxxx>pip uninstall pandas

In principle the pandas should be uninstalled.

surprisingly enough the pandas package can still be found in the enviroments anaconda navigator (also after close and open), and the jupyter version works (importing pandas does not give error)

if I go again to the anaconda prompt and type:

pip uninstall pandas

the message is: Skipping pandas as it is not installed.

So what is going on here? where is and where is not installed pandas? And above all what are the steps to run a pyhton program from

Btw, i tried to follow this instructions to run from CMD

thanks a lot

(xxxxxx for privacy reasons ofuscated)

4
  • 2
    You need to add the location of the Anaconda python to your "Environment Variables" -- seems it's not on your path Commented Mar 20, 2019 at 10:54
  • you can also try to use the anaconda prompt. there the paths are typically set correctly. (Press the windows key and type ana, then you should see it) Commented Mar 20, 2019 at 10:56
  • I can not edit the "Environment Variables" in windows because I dont have administrative rights. (in case you are wondering, yes I could install pyhton with Anaconda) Commented Mar 20, 2019 at 14:56
  • I tried adding the following to the .py code: sys.path.append(r"C:\Users\JF30443\AppData\Local\Continuum\anaconda3\Lib\site-packages\blaze\compute") print(sys.path) Commented Mar 20, 2019 at 15:28

1 Answer 1

3

In the case that you are using windows 10 you can also set environmental variables for your account even if you are no admin as explained here.

If you want to start the python code via anaconda in the cmd line you could use

set root=C:\ProgramData\Anaconda3\
call %root%\Scripts\activate.bat %root%
python yourcode.py

just make sure that the root directory matches your path

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.