Issue
I'm trying to run a py file in D drive from cmd to make it run in the background. Command used:
nohup python -u D:\project\Telegram_bot\Telegram_bot.py &
It is creating ImportError in the nohup.out file
Traceback (most recent call last):
File "D:\project\Telegram_bot\Telegram_bot.py", line 11, in <module>
from telegram.ext.updater import Updater
File "D:\Software\Anaconda\lib\site-packages\telegram\ext\__init__.py", line 31, in <module>
from .updater import Updater
File "D:\Software\Anaconda\lib\site-packages\telegram\ext\updater.py", line 22, in <module>
import ssl
File "D:\Software\Anaconda\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed while importing _ssl: The specified module could not be found.
Now running the command from conda promt with little change in the nohup command
nohup python -u D:\project\Telegram_bot\Telegram_bot.py &
This is working as expected but the issue is if I close the conda prompt the file stops executing.
NOTE: Anaconda is installed in my D drive not C drive(primary drive)
Solution
What the Anaconda Prompt does is it adds several folder to your system path: Not just the location of the interpreter, but also the location of the dll libraries.
If you are running from the cmd prompt, you probably just have the interpreter on the path, nothing else. This is why the dll import fails.
You ALWAYS have to activate conda before you have access to the full Anaconda Python installation. See activating an environment. Note that there is at least the base environment.
Answered By - Peter Answer Checked By - Marie Seifert (WPSolving Admin)