Python script can't open zmq-module - python

I've a problem with a python-script. In a script, i have:
import zmq
from datetime import datetime
import pytz
import bottle
import logging
from bottle import response
But, when i run this script, i see:
ImportError: No module named zmq
I've also tried:
import pyzmq
When i run: pip install pyzmq, it display's that the package already is installed.
But it doesn't works. The probleem arose after i have updated Python 2.6.x to Python 2.7. I think, the plugins are not included in the upgrade?????
Does anyone have an idea?

Related

No module named 'importlib.util' with Python 3.8

I encountered the following error:
File "D:\python-win\lib\distutils\util.py", line 9, in <module>
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
I am using python 3.8 (x64) on a windows 10 machine
D:\test> python --version
Python 3.8.10
and the latest pip
(.venv) D:\test> pip --version
pip 21.3.1 from d:\test\.venv\lib\site-packages\pip (python 3.8)
As the above message indicates the error is originating from util.py which is included in the lib/dist folder of the python 3.8 distribution for windows. The offending block is
"""distutils.util
Miscellaneous utility functions -- anything that doesn't fit into
one of the other *util.py modules.
"""
import os
import re
import importlib.util
import string
import sys
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
All of the info I could find indicated importlib was included with python 3+, but I am seeing this error anyway.
Is there something else I am missing?

ModuleNotFoundError, trying to use binance.websockets

Hi I thought this would be pretty straightforwards but I can't figure it out.
It can't find binance.websockets for whatever reason even though it can find binance.client which should be part of the same package?
import config
import os
from binance.client import Client
from twisted.internet import reactor
from binance.websockets import BinanceSocketManager
Running this import code gives this error
Traceback (most recent call last):
File "/home/lucho/Documents/cryptoAPIs/binance/importconfig.py", line 6, in <module>
from binance.websockets import BinanceSocketManager
ModuleNotFoundError: No module named 'binance.websockets
To get the library I installed with pip3
pip3 install python-binance
pip3 install binance-api
The BinanceSocketManager is no longer in the websockets file. Change your import to this:
from binance.streams import BinanceSocketManager
This will fix the issue
use this " pip install python-binance==0.7.9 "
If you look into the breaking changes on version 1.0.1 they mention they changes Websockets, so that is probably what you are hitting.
I would just reinstall the latest version "pip install python-binance" and use the up to date examples on their repo:
https://github.com/sammchardy/python-binance

ModuleNotFoundError: No module named 'utils.datasets'

I am using Python 3.6.8 on Windows 10
I installed tensorflow, keras, and utils using pip.
pip install tensorflow and it installs the version 2.0.0
pip install keras and it installs the version 2.3.1
pip install utils but it does not show what version I have installed.
This is my header:
from keras.preprocessing import image
from PIL import Image
from keras.models import model_from_json, load_model
import numpy as np
import cv2
from datetime import datetime
import os
import random
import string
from utils.datasets import get_labels
from utils.inference import apply_offsets
from utils.inference import load_detection_model
from utils.preprocessor import preprocess_input
This is my error:
from utils.datasets import get_labels
ModuleNotFoundError: No module named 'utils.datasets'
Why am I getting this error? And how to fix it? BTW The code was written by a previous programmer and I need to modify it. But I can't even run it. not so good in python tho. i'm just getting started to it.
All my google search are all purple but I can't seem to find any solutions.
EDIT
The suggested answer (ImportError: No module named datasets) does not satisfy my needs. I am having trouble on utils module. because when I comment out the line from utils.datasets import get_labels
The error is on the next line:
ModuleNotFoundError: No module named 'utils.inference'
The utils model what the code your provided want to import is the part of the oarriaga/face_classification project.
The pip installed utils modul is quite different package, so you should not have installed via pip. Your code try to import moduls from this package, but it obviously has no such moduls. That is why the error messages.
So what you have to do is pip uninstall utils and then if your project directory structure is complete, the above code will import the face_classification package's moduls.

"Importerror: no module named zope.interface", but I already installed on my Centos 7

Why I cant run this code? I already have zope.interface I have try update the path but still doesn't work, I don't know why. See the image above:
import paho.mqtt.client as mqtt
from twisted.internet import reactor, protocol
from txws import WebSocketFactory
import json
If you installed with pip there's a good chance it broke the installation.
After installing the zope module using pip, for example: z3c.password, your zope installation breaks.
This is because pip installs the module in /usr/local/lib/python2.7/dist-packages/zope and the original module zope.interface is in /usr/share/pyshared/zope/interface/ and has minor relevance when importing.
To fix this I would try symlinking it like so:
cd /usr/local/lib/python2.7/dist-packages/zope
sudo ln -s /usr/share/pyshared/zope/interface/

Can not install "posix" package using pip

I installed Anaconda on my PC (windows), then I tried to run the following:
import pdb
import sys
import os
import posix
sys.path.append(os.path.join(posix.environ['HOME'], 'mlprojects', 'swig', 'src'))
sys.path.append(os.path.join(posix.environ['HOME'], 'mlprojects', 'datasets', 'python'))
sys.path.append(os.path.join(posix.environ['HOME'], 'mlprojects', 'mlopy', 'netlab'))
##ENDSETUP
import ndlml as nl
import ndlwrap as nw
import numpy as np
import datasets
import netlab
import matplotlib.pyplot as pp
import matplotlib.mlab as ml
import matplotlib.axes
import math
After running the above code, I got the following error:
File "C:/Users/yat/test.py", line 9, in <module>
import posix
ImportError: No module named posix
When I tried pip install posix, I got the following message:
Collecting posix
Could not find a version that satisfies the requirement posix (from versions)
No matching distribution found for posix`
How do I install posix package, and where to find all installed packages in Anaconda?
That's a built-in module that's not available on Windows. Look at the documentation:
Do not import this module directly. Instead, import the module os,
which provides a portable version of this interface. On Unix, the os
module provides a superset of the posix interface. On non-Unix operating
systems the posix module is not available, but a subset is always
available through the os interface. Once os is imported, there is
no performance penalty in using it instead of posix. In addition,
os provides some additional functionality, such as automatically calling
os.putenv when an entry in os.environ is changed.
So just replace posix with os and you should be good to go.
To list all the installed packages with Anaconda, look at the docs:
List all of your packages in the active environment:
conda list
To list all of your packages installed into a non-active environment
named snowflakes:
conda list -n snowflakes

Categories