TMUX Session Won't Import Python Module

社会主义新天地 提交于 2019-12-23 12:53:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32543783/tmux-session-wont-import-python-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!