0

I'm trying to run my python script that I developed/tested through IDE and it's working fine over there.

But when I try to run the same script on Command Prompt (Windows 10) which has to import any module. Note that python script and the .bat file is in the same directory.

I think this is happening environment setup so I did some search and found these posts below;

import error: 'No module named' *does* exist

No module error when running python script from command prompt

Python command line Import Error

Unable to imoprt modules on python script while running on cmd

Package doesn't work if run from cmd or from the .py file.... PYTHON

https://www.programmersought.com/article/7436148385/

Here is the error snapshot

enter image description here

Steps followed

  1. Python version 3.8.3

  2. Environment variables are set under system environment variables enter image description here

  3. in the 'code.py' also added

    import sys
    sys.path.append('D:\program_files\anaconda3\Lib\site-packages')
    
  4. Seaborn and Scipy updated the latest versions

  5. CMD FILE look like this

enter image description here

I followed older solutions like set up environment variables for python libraries and python path so for not even close to get rid of this error.

Any idea to help what I'm missing here ?

Thanks

Alexander
  • 4,527
  • 5
  • 51
  • 98
  • Is it possible that your IDE is pointing to any specific virtual or conda environment? – BernardL Sep 21 '20 at 14:23
  • @BernardL This is what I got when I input print(sys.path) in `CMD` `'D:\\program_files\\anaconda3\\Lib\\site-packages', 'D:\\program_files\\anaconda3\\python38.zip', 'D:\\program_files\\anaconda3\\DLLs', 'D:\\program_files\\anaconda3\\lib', 'D:\\program_files\\anaconda3', 'D:\\program_files\\anaconda3\\lib\\site-packages\\win32', 'D:\\program_files\\anaconda3\\lib\\site-packages\\win32\\lib', 'D:\\program_files\\anaconda3\\lib\\site-packages\\Pythonwin', 'D:\\program_files\\anaconda3\\Lib\\site-packages\\IPython\\extensions'` – Alexander Sep 21 '20 at 14:35
  • Can you run `print(sys.prefix)` for both the IDE and default command line? – BernardL Sep 21 '20 at 14:42
  • @BernardL for CMD it is : D:\program_files\anaconda3 for IDE: D:\program_files\anaconda3 – Alexander Sep 21 '20 at 14:59

0 Answers0