By jj245941
I’m very very new to this. I have never used ubuntu before yesterday. I purchased a droplet through digital ocean and I setup the server. I installed python and all of the needed libraries for the script (it’s a simple twitter bot). I i created all the files inside a virtual environment… I think… I followed this guide. It was very helpful. So, I created these files, two of them. One .txt and one was .py . the Python file would take sentences from the txt file and send them to twitter basically. I am trying to run this script 24/7. I googled around and came across this thread . I was following what the user Mohensen stated, I was testing out my directory and things but I cant seem to access my python file. the path I was testing was: environments/my_env/Quotes.py I tried this and it stated “No such file or directory.” I tested it by adding /bin and /activate (both of them were required to access the files when i created them, I’m not sure why, but I had to type them) and it still did not work.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Solved! I saved the files inside of the envrionments directory not the bin directory!
Here is an alternative approach
First, when you created a virtual environment, it should have been done using a command like:
python3 -m venv my_env
This creates a directory (my_env) that contains the environment’s Python binaries, libraries, and scripts. To activate the environment, you would need to run:
source /path/to/my_env/bin/activate
Make sure you’re in the correct directory where the virtual environment is located when you run the above command. If you see (my_env) appear in your terminal prompt, it means the virtual environment is active.
Once your virtual environment is active, you should be able to navigate to your script. Assuming your script is stored inside the virtual environment folder, try this:
cd /path/to/my_env
And then list the files to ensure your Python script is there:
ls
If your Quotes.py file is in the correct folder, you’ll see it in the list. You should be able to run the script with:
python Quotes.py
If you’re still getting the “No such file or directory” error, double-check the exact location of Quotes.py by navigating to the directory where it’s stored and verifying the path.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.