I have a working script script.sh python /opt/facenet/src/train.py . But when I try to run it in cron, I get the following error: ImportError: No module named tensorflow . I tried to fix it this way: import tensorflow tensorflow.__file__ /home/user/anaconda3/lib/site-packages/tensorflow/__init__.pyc I changed the library path and ran the script like this: /home/user/anaconda3/lib/site-packages /opt/facenet/src/train.py , and then received the following error: /home/user/anaconda3/lib/site-packages: Permission denied . I tried to fix this with chmod, but it did not help either. I was asked to run the script like this: /home/user/anaconda3/bin/python /opt/facenet/src/train.py , but again I get the error: ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory . Any idea what could be wrong?
|
1 answer
I have seen similar problems when working with VirtualEnv . In this case, it will be convenient to create a small file in which all environment variables are set, for example:
Suppose you created Python VirtualEnv and named it ml (Machine Learning).
To work in scripts, you can create an environment file (let's call it: $ HOME / .ml_env):
export PYTHONPATH=/path/to/my/own/python_libs export LD_LIBRARY_PATH=$HOME/anaconda3/lib:$LD_LIBRARY_PATH export PATH=$HOME/anaconda3/bin:$PATH:$HOME/bin Then in the shell scripts add a trace. lines:
#!/bin/bash source $HOME/.ml_env conda activate ml - Thank you, your answer helped with the solution of my problem! - arti_lina
- @arti_lina, to thank the author of the answer, vote for the answer (you need to have at least 15 reputation points) and / or mark it as a solution ;-) - MaxU 7:47 pm
|
Permission denied? Try running likesudo- gil9red/home/user/anaconda3/bin/python /opt/facenet/src/train.py. Try to solve the problem withlibcublas.so.9.0. Take a look at this question at stackoverflow.com/questions/48428415/… - AndreyVirtualEnv? - MaxU