Forums

How to run a script on pythonanywhere

Hi, I am having problems knowing how to proceed. I have set up my virtualenv;

(myvirtualenv) c:\python34>

I have a machine learning code I couldn't run on my laptop due to memory issues...I want to run this code in the cloud...how do I proceed? Ideally, I need a shell to run in the cloud.

Please help as I am a newbie

Replied to your other question here

Check out our bash consoles and also our scheduled tasks. Or you could try to run the code using a jupyter notebook.

  1. My code needs to access data files currently saved on my laptop's desktop, I presume that I need to upload these files in pythonanywhere.

  2. I need sklearn for my machine learning code, it doesn't seem to be pre-loaded. I tried this yesterday by uploading the file for the code and running the code but got this message;

Traceback (most recent call last): File "/home/isaacalabi/.virtualenvs/TalkingDataModel.py", line 5, in <module> from sklearn.feature_extraction import FeatureHasher ImportError: No module named 'sklearn'

Please can you clearly respond to each of my points...please don't presume any prior knowledge on my part...apologies for asking basic questions.

  1. Yes, you'll need to upload your data files to your folders on PA. You can use the Files tab on the PA Dashboard. (You can also use an FTP client app with SSH/SFTP - search this Forum for further info if you want to do that.)

  2. If it's available via PyPI, you can use 'pip' from a Bash console to install it yourself, see https://help.pythonanywhere.com/pages/InstallingNewModules/.

HTH

Jim

  1. yup you will need to upload the files. see our help pages on different ways of uploading.
  2. so we do have sklearn installed, but the way virtualenvs works is that you dont get access to the outside system libraries if you use virtualenvs. So if you are doing that, you will need to install into the virtualenv yourself.

Thank you both for your help. I have been able to pip install the modules that I need.

I could not upload one of my files because it is too large. I need to learn how to use FTP client app.

Thank you for your help.

Another problem...I have installed a module which is housed here; home > isaacalabi > .cache > pip > wheels > d3 > 43 > 37

My code is housed here; home > isaacalabi > .virtualenvs > TalkingData.

When I run the code, I get this message;Traceback (most recent call last): File "/home/isaacalabi/.virtualenvs/TalkingData/TalkingDataModel.py", line 5, in <module> from sklearn.feature_extraction import FeatureHasher ImportError: No module named 'sklearn'

I presume I have to sort out the paths...how do I do this please?

Did you install it using pip install in the virtual env, with no errors?

You need to make sure that you are installing it inside of the virtualenv and not outside. ie. make sure that you have the virtualenv activated when you do the pip install.

Can't find the run button on script mode

Could you explain what are you trying to do? What do you mean by "script mode"?

Question: How do I use "script mode" in pythonanywhere? I am following a tutorial and it says, now create a script and run in by using script mode.

you run

python name_of_your_script.py

in the bash shell