test test_urllibnet failed in Linux - python-3.x

I want to install Python. I tried both Python3.3 and Python3.4 I downloaded the file from https://www.python.org/download/releases/ and followed the instructions.
I executed :
./configure
make
successful. But when execute :
make test
it failed for test_urllibnet.
So according the README file if executed for Python3.4:
./python -m test -v test_urllibnet
== CPython 3.4.0 (default, Apr 16 2014, 16:38:06) [GCC 4.8.1]
== Linux-3.11.0-15-generic-x86_64-with-debian-wheezy-sid little-endian
== hash algorithm: siphash24 64bit
== /home/bernard/Python/Python3.4/Python-3.4.0/build/test_python_27532
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_urllibnet
test_urllibnet skipped -- Use of the 'network' resource not enabled
1 test skipped:
test_urllibnet
So now it skipped because the 'network' is not enabled. But how to enable the 'network'? I could not find it.
On a different computer I try to install Python3.3 with all most the same error.
./python -m test -v test_urllibnet
== CPython 3.3.5 (default, Apr 24 2014, 17:18:29) [GCC 4.6.3]
== Linux-3.5.0-38-generic-x86_64-with-debian-wheezy-sid little-endian
== /home/bernard/Downloads/Python-3.3.5/build/test_python_6523
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)
[1/1] test_urllibnet
test_urllibnet skipped -- Use of the 'network' resource not enabled
1 test skipped:
test_urllibnet
Those skips are all expected on linux.
Notice this should be Ok for Linux. But in Python3.3 the statement
Python 3.3.5 (default, Apr 24 2014, 17:18:29)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named '_ssl'
So it is not Ok. The solution in python3.3.1 ssl module looks quite similar, but does not work for me.
I looked into
Building Python and more on missing modules
but also without result.
Just installing software, here Python, is escalating and gets real complex.

No solution for me, just a work-around. Installing just Python gets to complex and take to much time. Others seems to have the same problem.
The work around is just use the pre-installed Python2.7 which works. I tried to avoid Python2.7 as much as possible, but now I am obliged to use it. This answer may help to prevent people spend to much time in solving a problem which is hard to solve.

Related

ImportError: DLL Load Failed while importing fun: The specified module could not be found

Hello I have started using pybind11 on windows 10 and I am not using Visual Studio.
I have followed the tutorial I have watched on YT but he was using Linux and after I created my cpp file, I cloned the pybind11 in my current directory and after that I created a build folder.
As what the guy said in the YT, I created a CMakeLists.txt in my folder with something inside:
cmake_minimum_required(VERSION 3.9)
project(pb11Ex)
add_subdirectory(pybind11)
pybind11_add_module(fun, ex_moc.pp)
Then cd to my build directory and run
cmake .. -G "Unix Makefiles"
Cause if I don't add it, it wont gonna generate the makefile
Then after the cmake venerated a makefile, I used
make
command giving me the file:
fun.cp39-win_amd64.pyd
Then when I tried to import it from the python interpreter, I got this:
C:\Users\Nel\Desktop\python_projects\pyb11Ex\build>python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import fun
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing fun: The specified module could not be found
What does it mean by the DLL stuffs and how would I solve it?
Update:
I just followed the pybind docs

How to Determine where to install hidapi.dll?

Context: A Windows 10 attempt to install and test python hid per instructions:
pip install hid
The test to import the module failed:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hid\__init__.py", line 30, in <module>
raise ImportError(error)
ImportError: Unable to load any of the following libraries:libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-iohidmanager.so libhidapi-iohidmanager.so.0 libhidapi.dylib hidapi.dll libhidapi-0.dll
Released hidapi-win.zip includes pre-compiled:
hidapi.dll
hidapi.lib
Question: What is the thought process & facts necessary to determine the proper location to install the two files? Assume a recent new install of Windows 10 and Python 3.8
First, you need to Unblock them. Right-clik > Properties > Unblock
Place both files in the same folder where python.exe is.
The location of python exe can be found in the command line as where python
Paste the .dll and .lib file inside the Windows/System32 folder. After that restart the terminal and the hid module should find the library without a problem
I got the same issue. There was another version of hid installed in my system, after deleting the hid folder issue got solved. Check the version of hid still exits in this below "site-packages" folder.
C:\Users\OPERATOR\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages

How to link openCv with Python3 in mac Os

I have two versions of python in my mac os, the first python2.7 which is the default that came with the system. Later I installed python3.7 that I use most of the time.
I have recently installed openCV using homebrew.
When I'm using openCV with python2.7, it's working normally.
But the problem is when I try to use it with python3. Importing cv2 in python3 gives error: ModuleNotFoundError: No module named 'cv2'
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current
information.
>>> import cv2
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
>>>
Is there anything I can do so that I can link the installed openCV with python3 ??
Thanks for the help
Sorry I cannot give you specifics because your setup is not identical to mine, but I am sure we can get you sorted out.
Firstly, when you install packages, such as OpenCV, they tend to create a directory somewhere called lib which contains the C/C++ functions you can call from that package. Inside that directory, you normally find "shared object libraries" which traditionally end in "XXX.so" on macOS. More interestingly, they also contain a sub-directory called site-packages which contains the Python bindings (links). So, on my system, which is likely different from yours, I can find all those site-packages directories with:
find / -type d -name site-packages 2>/dev/null
Sample Output
/usr/local/lib/python3.7/site-packages
/usr/local/lib/python2.7/site-packages
...
...
/usr/local/Cellar/tbb/2018_U5/lib/python2.7/site-packages
/usr/local/Cellar/vips/8.6.5/lib/python3.7/site-packages
Hopefully, you can see that /usr/local/lib/python3.7/site-packages is looking a very likely candidate for where all the Python v3.7 bindings for OpenCV should be.
Good, so now we know how to find the Python bindings, we need to tell Python that information. How? Well, not unreasonably, Python looks at an environment variable called PYTHONPATH to find its stuff. So, using our skill and judgement we need to marry up what we found in the first step with what we now know from the second step. So we do:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.7/site-packages
And everything should work. All we need to do is put that in our login profile (probably $HOME/.profile) and we will be ready to go every time we log in.

Command line application shoogle requires python3 but Ubuntu 16 defaults to python 2.7

The command line application shoogle (https://github.com/tokland/shoogle) which exposes google api services at a terminal command line requires python3 but the ubuntu 16 default python is 2.7.
I have tried alias and calling the shoogle app from subprocess in a python3 shell but (of course) the os still provides the default. I have been reluctant to make system wide changes to .bashrc or PYTHONPATH e.g. as so many other resource expect 2.7. But I am currently using this on a virtual machine so if it does break I can recover. That seems the only option but impractical in a production environment.
I've found very little shoogle help online (the author suggests SO etc. for support) so if any one has any experience with shoogle or suggestions to get the requiured python version I'd be happy to hear.
Running shoogle from a python3 interpreter finds the 2.7 files:
3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609]
Python Type "help", "copyright", "credits" or "license" for more information.
from subprocess import call
call (['shoogle', 'show'])
Traceback (most recent call last):
File "/usr/local/bin/shoogle", line 11, in <module>
import shoogle
File "/usr/local/lib/python2.7/dist-packages/shoogle/__init__.py", line 5,
in <module> from .shoogle import *
File "/usr/local/lib/python2.7/dist-packages/shoogle/shoogle.py", line 14, in <module>
from . import commands
File "/usr/local/lib/python2.7/dist-packages/shoogle/commands/__init__.py", line 2, in <module>
from . import execute
Using #Surest Texans suggestions I uninstalled the shoogle app and used pip3 install to reinstall. Now the application works as expected when called from the command line.

install wxpython for python2 and 3 on ubuntu

I am running Ubuntu 16 and have both python 2 and 3. I have downloaded wxpython and it works with the python2 interpreter but not 3. I get
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>
and
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'wx'
What do I need to do to get installed for python 3?
A similar situation arises on Fedora 25, on which I was able to solve this. Your mileage may vary on Ubuntu.
First note that wxPython is available in two major versions, let's call them wx3 and wx4. You can identify your running version through import wx; print(wx.version()). The version string on Fedora 25 reads '3.0.2.0 gtk3 (classic)', i.e. a brand of wx3. On sourceforge these versions are known as 'wxPython' and 'wxPython4', and wxpython.org calls wx4 'phoenix'.
Inspecting the source code of wx3 you will note that wx3's syntax is incompatible with python3. Conversely, wx4 is compatible both with python2.7 and python3.
wx4 doesn't seem to be available on Fedora 25, therefore python3 can't run any wx out-of-the-box. Ubuntu may or may not have the same issue.
The following worked for me to install wx4 in a python3 virtual environment:
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-26 wxPython
I presume the answer to your question would be
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython
In case you need to port a (py2, wx3) application to python3, you would be wise creating an intermediate step: (py2, wx3) -> (py2, wx4) -> (py3, wx4), noting that (py3, wx3) is an impossibility.
To create the (py2, wx4) environment was more cumbersome for me, because the above pip install command fails to find header files when run using pip2.
What ended up working for me was to download the 4.0.0b2 source https://pypi.python.org/packages/bc/6f/f7bb525517557e1c596bf22ef3f242b87afaeab57c9ad460cb94b3b0714e/wxPython-4.0.0b2.tar.gz#md5=2e3716205da8f52d8039095d14534bf7
and follow the build instructions https://github.com/wxWidgets/Phoenix/blob/master/README.rst , from which I only used the build command python build.py dox etg --nodoc sip build .
After building, you need to tell your python2 where to find the wx4 library. I ended up doing that by creating a virtualenv, and creating a symbolic link like so:
/home/user/venv/lib/python2.7/site-packages/wx -> /home/user/downloads/wxPython/wxPython-4.0.0b2/wx
That latter directory cointaining the result of the build.

Resources