3

So I am trying to run a script from task scheduler. It has not been working and in the second that the terminal pops up and disappears, I was able to read it say "ImportError no Module named Pandas" My script imports Pandas fine and runs perfectly, but whenever I double click the script to run or schedule it to run automatically it is saying I do not have Pandas.

My theory is that it is using a different instance of Python that is installed on this computer that does not have the Pandas library installed. However, when i try to reinstall pandas on the command line using pip it sends back "requirement already satisfied". I would appreciate any advice or ideas for me to try. Thank you!

1
  • 1
    You are right you are using different versions of Python. python --version will give you the default version of Python in your system. You can use a specific version of python by typing python2.7 or python3.5 in the terminal. This will give you terminal access to the specific python. Different python versions present in your system will be available in the path: /usr/lib/python2.X. Commented Jun 16, 2017 at 18:16

1 Answer 1

3

sys.version_info and sys.version contain the version of Python that is being run. sys.executable contains the path to the specific interpreter running.

Python3:

>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
>>> sys.version
'3.4.3 (default, Nov 17 2016, 01:08:31) \n[GCC 4.8.4]'
>>> sys.executable
'/usr/bin/python3'

Python2:

>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
>>> sys.version
'2.7.6 (default, Oct 26 2016, 20:30:19) \n[GCC 4.8.4]'
>>> sys.executable
'/usr/bin/python2'

The problem seems to be that your registry editor has set a different version set to run "on-click" for Python executables. You can fix that by running the Python installer for the version you want, and setting it to repair, or modifying "HKEY_CLASSES_ROOT\Python.File\Shell\open\command" to run the correct python executable (Should be "C:\Windows\py.exe"). See this image for where to find it.

If you are already using py.exe, adding a hashbang to the top of the file (#!Python<version>, or to work with Unix executables, #!/usr/bin/env python<version>) should help py.exe pick the correct executable to run.

To install using pip for a specific executable, run Path\To\Executable -m pip install <module>.

To use modules from a different site-path, add the directory to the PYTHONPATH environment variable. Using import <file> will check for modules in directories in the PYTHONPATH.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.