Python only works with sudo

My python 2.7 script works on my Ubuntu system if I call it using

sudo python [filename].py 

or from bash script using

 sudo ./[bashscriptname].sh 

But if I call it from Pycharm, I get oauth errors and from the command line

 python [filename].py 

throws an error in the line "import pandas":

 ImportError: Missing required dependencies ['numpy', 'pytz'] 

I tried

But nothing works.

 pip list 

Shows all the necessary pandas, numpy, pytz, and oauth packages.

I have a noob who spent almost a day on this - help would be greatly appreciated!

+5
source share
1 answer

My group help solution should have noticed that when I tried sudo pip install pandas , I received a notification: Requirement already satisfied: pandas in /usr/lib/python2.7/dist-packages

I stuck sys.path.insert(1, '/usr/lib/python2.7/dist-packages') at the top of my script, and now it works fine.

Thank you so much @Joe !!

My next steps are the complete execution of my python installation, hopefully without sudos ... (thanks @xgord)

0
source

Source: https://habr.com/ru/post/1274986/


All Articles