Heroku Moduke Not Found Error - python

[![][1]][1]
the module 'pyicloud' is listed in requirements.txt
I have checked using the 'ls' command- I checked the directory in which the package should be - and the package does exist on the heroku server.
The app gives no such issues on my local machine, even though there is no difference in the code
I also tried the suggestions given here : https://help.heroku.com/BWJ7QYTF/why-am-i-seeing-importerror-no-module-named-site-when-deploying-a-python-app
but it didnt work.
(venv)dhcp-10-4-0-197:mes-amis mananhora$ heroku run python manage.py db upgrade -a mesamis
▸ heroku-cli: update available from 6.16.18-62346b1 to 6.99.0-ec9edad
Running python manage.py db upgrade on ⬢ mesamis... up, run.1121 (Free)
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from project import app, db
File "/app/project/__init__.py", line 40, in <module>
from project.import_data.functions import import_data_blueprint
File "/app/project/import_data/functions.py", line 6, in <module>
from pyicloud import PyiCloudService
ModuleNotFoundError: No module named 'pyicloud'

Related

ImportError when trying to use Django

apologies if this question has been asked a ton, I'm sure it has, and I've been trying for days to figure this out, but I can't wrap my head around it. I've been developing in Python for over 1.5 years, so I'm not a complete beginner.
I can't get Django to work in my command prompt. An example is, when I try to use py .\manage.py makemigrations this is what I get:
Traceback (most recent call last):
File ".\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".\manage.py", line 22, in <module>
main()
File ".\manage.py", line 13, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Now, I can see what the error says. The thing is my virtual environment is activated and it has Django installed, as seen here. Moreover, even if I executed outside my venv, it still doesn't work, even though I have all necessary Python directories in my PATH, as seen here.
I have verified that django-admin is installed on both my venv and my system, as well as Django itself, since I can import it on my Python Console. The version is 3.1.7. I have also tried reinstalling Django and it didn't work.
Another error I get, when I attempt to run Django console through PyCharm is this:
Traceback (most recent call last):
File "<input>", line 6, in <module>
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\conf\__init__.py", line 82, in __getattr__
self._setup(name)
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\conf\__init__.py", line 63, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I hope this helps you come up with any idea. Could anyone please share any insight on why I'm getting this? I would greatly appreciate it.
Edit: I have installed Django through PIP:
py -m pip install django
py -m pip install djangorestframework
py -m pip install django-admin
Also, Django is imported correctly from the Python Console within the venv:
>>> import django
>>> django
<module 'django' from 'C:\\Users\\user\\AppData\\Roaming\\Python\\Python39\\site-packages\\django\\__init__.py'>
in cmd to create a virtualenv
python -m venv virtualenv_name
to enable virtualenv
virtualenv_name\scripts\activate.bat
then
pip install django
and to create a project
django-admin startproject projectname
to run the project
cd projectname
python manage.py runserver

Start flask app from console - ModuleNotFoundError

Why, when I try to run a flask application from the console, I encounter an error: ModuleNotFoundError:
$ python run.py
Traceback (most recent call last):
File "run.py", line 1, in <module>
from src.app.controller import app
ModuleNotFoundError: No module named 'src'
or
$ env FLASK_APP=run.py flask run
* Serving Flask app "run.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "run", an ImportError was raised:
Traceback (most recent call last):
File "/home/pronect/PycharmProjects/it-informer-master/venv/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/pronect/PycharmProjects/it-informer-master/src/run.py", line 1, in <module>
from src.app.controller import app
ModuleNotFoundError: No module named 'src'
Here is a project screenshot:
But if I run the application from Paycharm, then everything works fine.
How to solve this problem?
Just try to change the code to this:
from app.controller import app
from config import Config
The file run.py is already in the directory src. The error occurs, because there is no other folder called src in the directory where the file run.py is stored.

Run Python scripts on Jenkins

I am trying to run my python automation on Jenkins. The scripts can be started on local PC. I already pip install 'request'. But when I try to start the scripts on Jenkins, it shows:
Building in workspace C:\Users\Desktop\Automation\CGN_automation
[CGN_automation] $ cmd /c call C:\Windows\TEMP\jenkins401971882258893188.bat
C:\Users\Desktop\Automation\CGN_automation>python testCase_100_856451.py
Traceback (most recent call last):
File "testCase_100_856451.py", line 9, in <module>
from cgnTestLib import *
File "C:\Users\Desktop\Automation\CGN_automation\cgnTestLib.py", line 2,
in <module>
import requests
ModuleNotFoundError: No module named 'requests'
C:\Users\Desktop\Automation\CGN_automation>exit 1
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

Django install and enviroment are no longer recognized

I just went to run my Django development server in the Django project that I'm working on and I got this...
(baseballwebenv) C:\DjangoProjects\BaseballWebsite\baseballweb>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "C:\Users\Nick\Anaconda3\envs\baseballwebenv\lib\site-packages\django\__init__.py", line 1, in <module>
from django.utils.version import get_version
File "C:\Users\Nick\Anaconda3\envs\baseballwebenv\lib\site-packages\django\utils\version.py", line 4, in <module>
import subprocess
File "c:\users\nick\anaconda3\Lib\subprocess.py", line 178, in <module>
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
ImportError: cannot import name 'ABOVE_NORMAL_PRIORITY_CLASS'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
As you can see I am by my runserver command, I am in my virtual environment. I recently upgraded all of my Anaconda packages, thinking everything was protected in the virtual environment. I would suspect this problem is related to that, but I'm not sure. How do I get my project up and running again? If someone wants to see certain files, I can add those as well.

Error running django with gunicorn and circus

I want to run django on an ubunu 14.04 machine , using gunicorn and circus. when I start gunicorn manually, it works fine, but when I try to run it with circus , this error occurs:
Traceback (most recent call last):
File "/path_to_my_app/venv/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/path_to_my_app/venv/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 10, in <module>
from gunicorn.app.base import Application
File "/path_to_my_app/venv/lib/python3.5/site-packages/gunicorn/app/base.py", line 9, in <module>
import traceback
ImportError: No module named 'traceback'
I have tried deleting virtual environment and creating it again, I have tested the ini file ...
any ideas?
the solution which itzMEonTV suggested, works fine. I don't know what the problem is though! I am using the same ini file that I have on another server. the only difference between these two systems, is the OS version. PYTHONPATH works fine on ubuntu 16.04 but not on 14.04.
anyway, the link suggested by itzMEonTV solved my problem.

Categories

Resources