Forums

Please Help. already set the the virtualenv with correct python version and installed the modules i need and still getting error

Hi,

I already set the virtualenv (in my case i called venv), installed the modules i need tfor my webapp and set the path at the web page (/home/ramosjosse/.virtualenvs/venv), but i still get the error:

2020-10-22 02:06:02,318: ModuleNotFoundError: No module named 'docx' 2020-10-22 02:06:02,318: File "/var/www/ramosjosse_pythonanywhere_com_wsgi.py", line 16, in <module> 2020-10-22 02:06:02,318: from CDC_Flask import app as application # noqa

please, help

Is your web app configured to run with that virtualenv? There's a place on the web app configuration page where you can specify which virtualenv to use. Also, if you're installing things, make sure you're installing them into the virtualenv that your web app is using.

Yes....

here is what i set:

Use a virtualenv to get different versions of flask, django etc from our default system ones. More info here. You need to Reload your web app to activate it; NB - will do nothing if the virtualenv does not exist.

/home/ramosjosse/.virtualenvs/venv

i read this topic: https://www.pythonanywhere.com/forums/topic/14766/. unfortunately, when i try to run it from the script with the "run" i still get almost the same error, even putting the hashbang!

Then you have not installed the module into the virtualenv that you're using. Make sure that the virtualenv is activated when you install the module.

Yes....im sure the venv wat activates when i installed de module. Look what happend if i try to install it again:

(venv) 16:50 ~ $ pip install python-docx                                                                                                                                                                            
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: python-docx in ./.virtualenvs/venv/lib/python3.7/site-packages (0.8.10)
Requirement already satisfied: lxml>=2.3.2 in ./.virtualenvs/venv/lib/python3.7/site-packages (from python-docx) 
(4.6.1)

"venv' is the name of my virtual enviroment

I saw sometimes you ask for permission to check the user account a find what is the issue, right? Can u help me doing this? it would great if u can help me fixing the problem.

The current error for your web app is not that docx is failing to import. It is that you have a template missing. It is not being found because you are using a relative path without paying attention to what your working directory is. See https://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/ for how to use absolute paths so your web app can find the template.

OK! Ill try to fix.it. thanks

So, the issue was:

enter code here
File "/home/ramosjosse/.virtualenvs/venv/lib/python3.7/site-packages/flask/templating.py", line 89, in 
_get_source_fast
 raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: /home/ramosjosse/mysite/templates/01_pagina_inicial.html

Teh solution u pointed:

The fix is to use the full, absolute path, instead of a "relative" path. So, eg:

/home/yourusername/project-folder/myfile.txt

But, the path of my templates are just as its being instructed in the page you pointed. Insnt it?

/home/ramosjosse/mysite/templates/01_pagina_inicial.html

In fact, this is teh path where my templates are. and, im not doing wRoNG cAsINg

Ok! Its working now.......as im using render_template...and the files are in the "templates" folder...a just set the path as "template_name.html"

Glad to hear you got it working!