Search code examples
pythonvirtualenvremote-servermodulenotfounderror

How to export virtual environment on a remote server?


I want to run python scripts on a remote server. I put my code under a directory using FileZilla, and I connect to the server using PuTTY. When I run my scripts, I have a ModuleNotFound error because I didn't install packages on the remote server. However, I'm not allowed to do a pip install on the server.

So I thought about using a virtual environment to manage it. But how can I export the virtual environment on the remote server?

Or is there a better way to manage it?

Thank you


Solution

  • use this command on cmd of you computer

    pip3 freeze > requirements.txt
    

    then copy the file the virtual remote directory the open cmd in virtual remote

    cd C://< where you copied the file>
    pip install -r requirements.txt
    

    or you can use this suggestion https://stackoverflow.com/a/31684470/16270009