Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TMUX Session Won't Import Python Module

Hi everyone this is my first question on StackOverflow and I hope it finds everyone well. I recently started using TMUX and I'm having a problem using it for a machine learning problem set I have.

I'm creating a program using python and I'm using the sklearn module. Basically when I run the code in the terminal out my TMUX session, everything works fine. However, when I start a TMUX session and run the code, I get the following error.

Traceback (most recent call last):
  File "hw1.py", line 5, in <module>
    from sklearn import svm
ImportError: No module named sklearn

For some reason, it can't find sklearn even though it is installed and it works fine outside the TMUX session. Here are my import statements.

import numpy 
import scipy.io
from sklearn import svm
from random import sample 

Why can't it find the module while in TMUX and how do I fix this?

like image 257
James Musk Avatar asked Sep 12 '15 21:09

James Musk


1 Answers

I ran into the same problem on OS X. It seems that the PATH variable gets messed up when you call tmux while in a non-default anaconda environment. If I run tmux in a new terminal before calling source activate and then activate the environment I want while in tmux then things work as expected. Unfortunately with this workaround I have to remember to call source activate in every pane I open in tmux so it's a less than ideal solution.

like image 169
tomsgd Avatar answered Sep 25 '22 02:09

tomsgd