Can anyone help me to figure out what is happening and how to solve this error?
The following message happens when I try to import a module I compiled before:
Python 3.1.4 (default, Mar 8 2012, 09:13:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python3.1/site-packages/pypt.so: undefined symbol: PyUnicodeUCS4_FromString
Related
I am new to python. I am currently porting our python2 code to python 3. subprocess does not work me. I always get the error
AttributeError: 'NoneType' object has no attribute 'decode'
when I call subprocess.run, subprocess.check_output, etc.
Example:
$python3
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import subprocess
subprocess.run(['echo','123'])
123
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 405, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 849, in communicate
return (stdout.decode(), stderr.decode())
AttributeError: 'NoneType' object has no attribute 'decode'
Something is wrong with your Python installation. I ran the same exact code using same version of Python and it got run successfully.
~|⇒ python3
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.run(['echo', '123'])
123
CompletedProcess(args=['echo', '123'], returncode=0)
Try to uninstall and install Python again, that might help.
I am getting this error while importing allennlp,
from allennlp.common.util import sanitize
ModuleNotFoundError: No module named 'allennlp.common'
(venv-kbs) administrator#NLR:~/aman/Project$ python
Python 3.6.3 (default, Oct 6 2017, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import allennlp
>>> from allennlp.common.util import sanitize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'allennlp.common'
My allennlp version is 0.2.1 and even trying to update to 0.4.1 it gives the same error.
TIA
Do check python version, Allennlp keeps pushing updates on regular period and thing works according to Python as well as Pytorch version.
I am unable to dynamically import a module which I have no problem importing in code and I have no idea why.
I have the following:
> ls lib
__init__.py main.py
The init file is empty. The following works:
> python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lib.main
>>> lib.main.sayyay()
yay
The following does not work:
> python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>> importlib.import_module("lib.main")
<module 'lib.main' from '/some/path/lib/main.py'>
>>> lib.main.sayyay()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'lib' is not defined
I did read the importlib documentation as well as a couple of answers here on SO, e.g., How to import a module in Python with importlib.import_module and Dynamically import a method in a file, from a string
But what am I missing?
import_module returns the imported module.
Therefore, you need to give the imported module a name and use this just like lib.main
>>> lib_main = importlib.import_module("lib.main")
>>> lib_main.sayyay()
So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet.
Please let me know how I can fix this issue so that I can use Django on my computer.
:~$ python
Python 3.5.2 (default, Nov 6 2016, 14:10:16)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
>>> exit()
I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.
I've been trying to run a colleague's script and though I have pandas running now, tkinter fails to load for some reason:
D:\>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\tkinter\__init__.py", line 36, in <module>
from tkinter import _fix
File "C:\Python34\lib\tkinter\_fix.py", line 65, in <module>
import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application.
I was under the impression tkinter shipped with Python 3.4?
My computer is a 64-bit machine running Windows 7 if that makes a difference?