No module names 'notifications.signals'; 'notifications' is not a package - python-3.x

Hello I have a problem with a Django project. When I ran in Pycharm the celery I got this error :
No module named 'notifications.signals'; 'notifications' is not a package
Althought when I type in Python Console this :
from notifications.signals import notify
Could you help me please ?
Thank you very much

If you configure PyCharm to use the same environment that you used when you executed successfully the import statement, then it will all work as expected.

Related

Python Module not found, but it is installed?

I wanted to make an Instagram bot so I can automate my posts and whatever. My problem is, I get the following Error when I try importing the module/library named "instagrapi":
Exception has occurred: ModuleNotFoundError
No module named 'instagrapi'
File "C:\Users\Simon\Desktop\Py\bot.py", line 1, in <module>
from instagrapi import Client
the error is in line 1 of my code, which simply states "from instagrapi import Client"
Now to my question: I already installed instagrapi, but VSCode tells me I didn't. I installed Python 3.11 but it runs in 3.10 or what so ever.
If someone can help me, please do so, thanks in advance
I tried reinstalling the library and restarting vscode, but it didn't help.
I'm running out of ideas

ModuleNotFoundError: No module named pickle for py3.7

I am receiving this error from command prompt: ModuleNotFoundError: No module named 'pickle' running in python 3.7,
I have it setup like this:
import pickle as thisPickle
What can be the reason why I having this import issue, appreciate any help. Thanks.
pickle is a part of the Standard Library and is pre-included in the Python package. There should not be a reason that it does not work. Make sure that no other versions of python exist on your computer. The command prompt may be using outdated versions that still exist. Also, see if other modules install correctly on your machine.

Unable to import 'scrapy_splash' pylint(import-error)

when trying to import Splash Request in VS Code, I get the following error message:
Unable to import 'scrapy_splash' pylint(import-error)
Do you know why this is the case? I have Splash up and running and the package is installed in my environment. I am using Python 3.7
Here is a screenshoot
Problem solved, I was in the wrong environment. You can change the environment in the command pallete (Ctrl+Shift+P) and enter Python: Select Interpreter

How to fix "ImportError: cannot import name 'flags' " while importing flags from Cleverhans.compat in Python

I am having a problem while playing the following code given as example in Cleverhans Library :
The problem is on Line # 18 . When it plays it gives out an import error :
ImportError: cannot import name 'flags'
I have tried to see in the help and there is also no flags function listed there.
from cleverhans.compat import flags
This should work by simply importing the module and giving no error.
I found the solution.
If any such error appears then its due to the problem in the way you have set your environment to work in .
If the dependencies are perfectly aligned then there comes no such error.
Thanks :)
P.S. If you find such error while running your code in Cleverhans then drop me a message . I'll be happy to help :)
To anyone that needs a solution:
replace from cleverhans.compat import flags with from tensorflow.python.platform import flags
if you are using pycharm, maybe you should open all the project 'cleverhans-master', and right-click on it,select mark directory as---source root. And it could be imported normally.

PIP installed pywin32 service fails: Incorrect function

Running Python 3.6.5, PyWin32 223.
After install I have included the the C:\Python32\lib\win32 folder in path.
I am just running the normal testService shell that seems to be all over the internet. Can be found below.
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None,0,0,None)
socket.setdefaulttimeout(60)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.main()
def main(self):
pass
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)
I can "compile" and install the service fine, as soon as I run it I get an error to check the system logs. When I do I get the following error.
The Test Service Process service terminated with the service-specific error Incorrect function..
I have not been able to find any help through google from this decade. I am new to the library and the only help I found was to add its lib to the path. If its a path error, its no longer that. Anyone have any ideas?
Thanks in advance!
It turns out that it was a permission issue. I request root for 30 seconds and worked like a charm. Just FYI if anyone is having this problem.
In my case the problem was in the way I run the python module. Instead of executing the Python script, I use
$ python -m module
This works correctly when running in the appropriate directory but when running as a service, the module could not be found. So the solution if executing modules directly with Python is to pip install the module so that it can be found by the service.
In my case was due to the fact that the python script I was trying to run as a service wasn't in the same drive of the python installation. Also check this useful answer.

Resources