ImportError during python run - python-import

Currently I am executing doamusic python codes from
https://github.com/yump/doamusic.git
I am using python 3.7.2. (Python IDLE) on windows.
My directory tree is
F:\doamusic_project\doamusic\music.py
when I run music.py, I am getting the following error
Traceback (most recent call last):
File "F:\doamusic_project\doamusic\music.py", line 31, in
from . import util
File "..\doamusic__init__.py", line 1, in
from doamusic.music import *
File "..\doamusic\music.py", line 32, in
from . import _music
ImportError: cannot import name '_music' from 'doamusic' (..\doamusic__init__.py)
What is the reason for not importing _music ?.

You are trying to do an import from .pyx file. A .pyx file must be compiled unlike a .py file.
Try to do that before the import of _music:
import pyximport
pyximport.install()
More info Cython

Related

SyntaxError: future feature annotations is not defined for dockerize

Im trying to dockerize my project, but ran into the following error, not sure what is the error about.
Traceback (most recent call last):
File "server/main.py", line 5, in
from fastai.vision.all import *
File "/usr/local/lib/python3.6/site-packages/fastai/vision/all.py", line 1, in from . import models
File "/usr/local/lib/python3.6/site-packages/fastai/vision/models/init.py", line 1, in
from . import xresnet
File "/usr/local/lib/python3.6/site-packages/fastai/vision/models/xresnet.py", line 12, in
from ...torch_basics import *
File "/usr/local/lib/python3.6/site-packages/fastai/torch_basics.py", line 9, in
from .imports import *
File "/usr/local/lib/python3.6/site-packages/fastai/imports.py", line 30, in
from fastcore.all import *
File "/usr/local/lib/python3.6/site-packages/fastcore/all.py", line 3, in
from .dispatch import *
File "/usr/local/lib/python3.6/site-packages/fastcore/dispatch.py", line 4
from future import annotations
^
SyntaxError: future feature annotations is not defined
Im doing this on VSCode
Managed to trouble shoot the problem and resolved it.
For python version issue
Dockerfile to change python version from 3.6 to 3.10
for the various requirement issue
update requirement.txt to latest versions as prompted by the terminal as you run the dockerize process in the terminal.
hope this helps for all future people who encounters the same problem

Python test fails printing dependency on local package

I thought that bazel runs tests in sandbox, but recently I got an error pointing to a local module /usr/lib/python3/dist-packages/OpenSSL/SSL.py. It it correct? How to make bazel run in a sandbox?
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //master:master_impl_test
-----------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl_test.py", line 14, in <module>
from master import master_impl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl.py", line 20, in <module>
from azure.cosmos import cosmos_client
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__azure_cosmos/azure/cosmos/cosmos_client.py", line 25, in <module>
import requests
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__requests/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__urllib3/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 675, in <module>
_lib.Cryptography_HAS_TLSEXT_HOSTNAME, "SNI not available"
AttributeError: module 'lib' has no attribute 'Cryptography_HAS_TLSEXT_HOSTNAME'
Today my project's CI get this error. I fixed this problem in my project, just upgrading pyOpenSSL library to latest version.
Old requirements-file.txt:
requests
pyOpenSSL==19.0.0
urllib3==1.25.3
New requirements-file.txt:
cffi==1.14.4
cryptography==3.3
pycparser==2.20
pyOpenSSL==20.0.0
six==1.15.0
urllib3==1.25.3

Unable to launch spyder

I get this error when I launch Spyder through cmd
Also, I can't run it by clicking the shortcut
Traceback (most recent call last):
File "C:\Akash Shanmugaraj\anaconda3\Scripts\spyder-script.py", line 6, in <module>
from spyder.app.start import main
File "C:\Akash Shanmugaraj\anaconda3\lib\site-packages\spyder\app\start.py", line 22, in <module>
import zmq
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from partially initialized module 'zmq.backend.cython' (most likely due to a circular import) (C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py)
I had the same problem. "activate base" didn't help, but just found a solution. Certainly not quite correct, but it works.
Go to folder:
C:\Users\<your_login>\AppData\Roaming\Python
and rename it ("Python") on "Python_x" or something else.
Spyder and Navigator starts up and so far everything works, but don't delete that folder.
In cmd try activating the base environment(or any other relevant environment) by running
activate base
and then try running spyder.

Jython: where is itertools?

In Jython 2.5.3, trying to import itertools:
>>> from itertools import product
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name product
Yet if you see this page from Jython docs itertools looks a core part of Jython since 2.3.
What do I need on the syspath to import iterools?
itertools.product is not available in Jython 2.5. The function was added in CPython 2.6, and is available in Jython 2.7.
See also https://wiki.python.org/jython/JythonFaq/GeneralInfo#Is_Jython_the_same_language_as_Python.3F.

ImportError when importing from Bio.PDB

I want to use Biopython's PDBParser to download PDB files, but this error appears when I try to import it:
Traceback (most recent call last):File "C:\Python27\TAREA 3 FINAL.PY", line 33, in [HTML] from Bio.PDB import * File "C:\Python27\lib\site-packages\Bio\PDB_init_.py", line 15, in [HTML] from PDBParser import PDBParser File "C:\Python27\lib\site-packages\Bio\PDB\PDBParser.py", line 13, in [HTML] import numpy ImportError: No module named numpy
What's going on here?
Biopython requires the numpy module. You need to install numpy in order to use Biopython. You can find the latest version here.

Resources