mickNeill
mickNeill

Reputation: 346

New to anaconda and spyder. using different sys.executables

For some reason when I install a package through Anaconda, it is not available in Spyder. When I execute the following command in anaconda and in spyder I get different files.

Anaconda:

import sys; sys.executable
'C:\\Users\\onp1ldy\\AppData\\Local\\conda\\conda\\envs\\deeplearning\\python.exe'

Spyder:

import sys; sys.executable
'C:\\Users\\onp1ldy\\AppData\\Local\\conda\\conda\\envs\\deeplearning\\pythonw.exe'

Can anyone help me with this? I am not sure what to do...

Upvotes: 3

Views: 916

Answers (3)

Muhammad Usman Bashir
Muhammad Usman Bashir

Reputation: 1519

By Default: You can control which one of the executables will run your script. Such as, when opened from Explorer by choosing the right file_name like:

1. python.exe is a terminal-based (console) application to run and lunch CLI-Type Python-scripts.

*.py files are by default associated (invoked) with python.exe

2. pythonw.exe is a GUI-based app for lunching Graphical User interface-(No_UI_at_all_Scripts)

*.pyw files are by default associated (invoked) with pythonw.exe

TO SUMMARIZE AND COMPLEMENT MY OPINION:

First of all, Python-Binary that you're trying to run doesn't have Package installed. It does have a directory path named as package_name like torch at the search path of modules, and it is being treated as a Package namespace like for me:

torch.Tensor(5, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torch' has no attribute 'Tensor'

For your current python binary, you need to install your package correctly. Visit Reference: Home-Page

python3.7 -m pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl 
python3.7 -m pip install torchvision

More importantly, replace the pip or pip3 as the Home-Page instructions use with python3.7 -m pip;. In the end, don't forget to include python3.7 to be the full path to your Python binary.

Upvotes: 2

Andrea Grioni
Andrea Grioni

Reputation: 187

based on your description the problem may be connected to the Python interpreter that you are using in Spyder. There is a similar issue on Stack Overflow at this url:

Issue on Anaconda and Spyder

You can try the solution proposed by Bremsstrahlung.

Hope this can help you.

Upvotes: 0

Sachin Prabhu
Sachin Prabhu

Reputation: 152

Run this in spyder and see if you can access the package.

import subprocess

subprocess.call('pip install numpy', shell=True)

import numpy

Upvotes: 0

Related Questions