I have installed zmq and pyzmq.But I can't import pyzmq.
>>> Successfully installed pyzmq
Cleaning up...
hepeng#hp:~$ python
enter code here
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyzmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyzmq
But I can import zmq.
>>> import zmq
>>>
So why?Thanks.
pyzmq is the PyPI package installer name, but the actual root package is named and imported as zmq. This is just how some Python packages work; PyYAML is another example, being installed under the name PyYAML, but imported as yaml.
If you take a look at the zmq docs or pyzmq API, you'll notice all the Python examples import as zmq.
Related
list the packages beginnig at s.
pip list | grep ^s
setuptools 56.0.0
six 1.12.0
sniffio 1.2.0
socks 0
Why the version number is zero?
python3
Python 3.9.6 (default, Jul 14 2021, 09:15:03)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socks
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'socks'
debian#debian:~$ pip3 install socks
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: socks in /usr/local/lib/python3.7/dist-packages (0)
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
debian#debian:~$ python3
Python 3.9.6 (default, Jul 14 2021, 09:15:03)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socks
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'socks'
What is the matter with package----socks in my python?
pip might not be pointing to python3 ?
python3 -m pip list | grep ^s
selenium 3.141.0
setuptools 56.0.0
six 1.16.0
sniffio 1.2.0
socks 0
If you're unsure you have socks installed, use:
pip install socks
in the command prompt. That way it will either tell you that it's installed or install it for you
I've deployed my first package in test.pypi.org as you can find it here
I have installed my package in my virtual environment (.venv).
$ pip list
returns :
Package Version
---------- -------
pip 20.1
pyupurs 0.0.2
setuptools 46.0.0
wheel 0.34.2
But as you can see here, I cannot import it within my interpreter.
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyupurs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyupurs'
Why is this happening? How can I fix it?
In your package pyupurs there is nothing that can be imported under same name. The distribution package pyupurs installs top-level importable package named stateless_file_ops. So you can only do
import stateless_file_ops
If you want to change that you need to change you subdirectory structure perhaps adding a directory pyupurs with file __init__.py in it.
I have multiple pythons installed in my machine, 2.7, 3.5, 3.6, etc and I installed the library called spacy.
And it seems like this library keeps referring to the old version of python which is 3.5. at /usr/local/lib/python3.5/dist-packages.
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/spacy/__init__.py", line 4, in <module>
from . import util
File "/usr/local/lib/python3.5/dist-packages/spacy/util.py", line 4, in <module>
import ujson
ModuleNotFoundError: No module named 'ujson'
Regardless of this specific library 'spacy', I'd like to know
what is the best way to make library to point to upgraded python which is 3.6, not 3.5. Which path variable should I update?
Please help... I've been wasting too much time on this issue.
Try to install spacy lib by running pip with required python version in module mode:
python3.6 -m pip install spacy
I installed the latest version of lxml.etree compatible with Python 3.4. However when I try importing the package, I hit the following error:
> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /users/vinapai/nxapi/pyats/lib/python3.4/site-packages/lxml/etree.cpython-34m.so: undefined symbol: xmlMemDisplayLast
>>>
I tried using both pip install and easy_install and tried different packages of lxml but consistently hit this error. Any help would be greatly appreciated.
I'm trying to install pyOpenSSL using pip, python version is 2.7, OS is linux.
After pyOpenSSL installed, when I tried to import the module in python, I got the following error:
Python 2.7.5 (default, Jun 27 2013, 03:17:39)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 84, in <module>
OP_NO_TICKET = _lib.SSL_OP_NO_TICKET
AttributeError: 'FFILibrary' object has no attribute 'SSL_OP_NO_TICKET'
>>>
I tried to uninstall pyOpenSSL and install it again, but got the same error.
This is because low version pyopenssl has not defined SSL_OP_NO_TICKET。
clone the latest pyopenssl from https://github.com/pyca/pyopenssl.git and install it, then that'll be fine. no thks.
The fix is described here:
https://github.com/pyca/pyopenssl/issues/130
Indeed, you can apply it manually (not really recommended, but easy)
Or download archive from github
The link to the fix: https://github.com/pyca/pyopenssl/commit/e7a6939a22a4290fff7aafe39dd0db85157d5e05
And the fix applied to SSL.py
-OP_NO_TICKET = _lib.SSL_OP_NO_TICKET
+try:
+ OP_NO_TICKET = _lib.SSL_OP_NO_TICKET
+except AttributeError:
+ pass