Forums

ModuleNotFoundError at / No module named 'watson_developer_cloud'

I have my local code with 'watson_developer_cloud' module running on my machine. When I pushed my code on PythonAnywhere, I am getting error as ModuleNotFoundError at / No module named 'watson_developer_cloud'.

I have installed this module using following command: pip3.6 install --user watson-developer-cloud --upgrade

Can anyone help me with solution for this problem?

TIA.

if you are going the install --user route, that installs on top of system python, not into a virtualenv python. If you are using a virtualenv, you should make sure you have the virtualenv activated so that you are installing to the virtualenv python and not the system python, and you should just be doing a pip install (without --user)

Thank you for your reply. I tried to install into my virtualenv, and getting following errors:

Exception: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/local/lib/python3.6/dist-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/usr/local/lib/python3.6/dist-packages/pip/req/req_set.py", line 784, in install **kwargs File "/usr/local/lib/python3.6/dist-packages/pip/req/req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "/usr/local/lib/python3.6/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python3.6/dist-packages/pip/wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "/usr/local/lib/python3.6/dist-packages/pip/wheel.py", line 287, in clobber ensure_dir(dest) # common for the 'include' path File "/usr/local/lib/python3.6/dist-packages/pip/utils/init.py", line 83, in ensure_dir os.makedirs(path) File "/usr/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.6/site-packages'

Can you help me with solution for this problem?

You're not installing into a virtualenv. That stacktrace indicates that you're trying to install into the global shared Python. Activate your virtualenv before installing.

So I have followed the instructions given on Installing New Modules page on PythonAnywhere link here. Followed instructions for installing command modules without being in virtual environment and with virtual environment as well. With both methods, it is installing modules in /home/< user name >/.local/lib/python3.6/site-packages Whereas, I want to install modules in /home/< user name >/< project directory name >/myvenv/lib/python3.6/site-packages. Can anyone help me with one of the following:

  • How can I install modules in /home/< user name >/< project directory name >/myvenv/lib/python3.6/site-packages directory?

OR

  • How can I set default directory for modules as /home/< user name >/.local/lib/python3.6/site-packages for my project? It is really urgent.

If you follow the virtualenv instructions on the help page on installing new modules, it will put the modules in /home/username/.virtualenvs/virtualenvname/lib/python3.6/site-packages. If you want to put your virtualenv in a specific place, then you can use the raw virtualenv tool instead of mkvirtualenv. So, for your example, you would create it with

virtualenv /home/USERNAME/PROJECTDIRECTORYNAME/myvenv/ --python=python3.6

Then to install stuff into it, you would make sure it's activated:

/home/USERNAME/PROJECTDIRECTORYNAME/myvenv/bin/activate

...and then use pip to install stuff

pip install PACKAGE

If you're working on a website, and you want it to use those packages, then make sure it's configured to use the correct Python version (3.6 in the example above) and then enter the full path to the virtualenv into the relevant field on the "Web" tab -- for example, /home/USERNAME/PROJECTDIRECTORYNAME/myvenv/