For some reason, anytime I try to import a python library, a particular old error message keeps popping up.
However, everything works fine when working with shell.
I know this is not a real programming question, but I'm stuck and would appreciate any help.
Any ideas on how to fix this?
Error message
>>> import nltk
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import nltk
File "C:\Python27\lib\site-packages\nltk\__init__.py", line 91, in <module>
from internals import config_java
File "C:\Python27\lib\site-packages\nltk\internals.py", line 22, in <module>
except ImportError: from xml.etree import ElementTree
ImportError: No module named etree
Does "C:\Python27\lib\xml\etree\ElementTree.py" exist in your computer?
Since IDLE and shell behaves differently, you may try the two lines in IDLE and Shell:
import sys
sys.path
Then check the difference of env path
Related
I've started playing around with pygame and pythonw recently, however whenever I attempt to import a majority of modules pythonw either imports incomplete modules or fails to import entirely.
All of the importing errors involve a Expected in: Flat Namespace
error with one of the many .so files in my conda3 python directory, which led me to believe that they were being loaded incorrectly by python or that they were broken; however, the modules all imported correctly in regular python.
I've ruled out the pythonw being located in a directory with nonexistent modules, as running sys.path in python and pythonw returns the same list.
Example of error, with the default-loaded help() command in Python(w) idle:
>>> help()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/lib/python3.6/_sitebuiltins.py", line 102, in __call__
import pydoc
File "/anaconda3/lib/python3.6/pydoc.py", line 63, in <module>
import platform
File "/anaconda3/lib/python3.6/platform.py", line 116, in <module>
import sys, os, re, subprocess
File "/anaconda3/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ImportError: dlopen(/anaconda3/lib/python3.6/lib-dynload/_posixsubprocess.cpython-36m-darwin.so, 2): Symbol not found: __Py_set_inheritable_async_safe
Expected in: flat namespace
Referenced from: /anaconda3/lib/python3.6/lib-dynload/_posixsubprocess.cpython-36m-darwin.so
In the case of pygame, modules such as font are loaded incorrectly and instead replaced with pygame.MissingModule objects
>>> pygame
<module 'pygame' from '/anaconda3/lib/python3.6/site-packages/pygame/__init__.py'>
>>> pygame.font
<pygame.MissingModule object at 0x10e8b5400>
>>>
Does anyone have any idea what is happening here? Any help would be greatly appreciated!
EDIT: [1]: https://i.stack.imgur.com/jDBrB.jpg
I have a python program to which I am adding GPIO pin control functionality. It is a multi-threaded system that runs fine until I try to do an "import RPi.GPIO as GPIO". Then I get the error below:
Traceback (most recent call last):
File "/usr/local/System/main.py", line 20, in <module>
from LightUpAlarm import AlarmCli
File "/usr/local/System/LightUpAlarm/AlarmCli.py", line 26, in <module>
from AlarmManager import AlarmManager
ImportError: No module named AlarmManager
The module "AlarmManager" was available until I tried to import "RPi.GPIO". I would appreciate any help understanding what I am doing wrong. Thanks in advance.
Pastebin link to full python file generating error. AlarmThread.py
I run linux mint 17.2 XCFE on my computer.
My issue is nearly identical to the one found in this thread, except I tried all of the solutions offered and none worked. It's worth noting that as a result of me trying to fiddle with python, my machine now runs 2.7.8 and the venv runs 2.7.6, which is easy to fix but might be relevant.
I also consulted this and this, and tried changing the name of file called operator and a different virtualenv command as suggested in those, but nothing worked. (Note: I then changed the name of that file back to operator just because since that wasn't the problem I'd rather not mess with it).
When I try to run a very simple script for flask newbs I keep encountering the same error.
(venv)joshua#joshua-ThinkPad-Edge-E430 ~/website/projects/helloapp $ python hello.py
Traceback (most recent call last):
File "hello.py", line 1, in <module>
from flask import Flask
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
from . import json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
from itsdangerous import json as _json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/itsdangerous.py", line 14, in <module>
import hmac
File "/home/joshua/anaconda/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
I have been trying to figure out a solution on my own for hours but I've had no luck. I think it might have to do with Anaconda but I'm not sure what could be done if that's the case.
As it turns out the issue was that the hmac.py file had a reference to a method that it appears no longer existed. I disabled that reference with '#' (just incase it turns out it was important) and it started working.
I want to execute below command but cygwin gives the error.
Please help me.
Python makeReadingsFile.py eichstaett.net.xml test.readings.xml
Traceback (most recent call last):
File "makeReadingsFile.py", line 75, in <module>
import argparse
ImportError: No module named argparse
As noted, the error message
$ Python makeReadingsFile.py eichstaett.net.xml test.readings.xml
Python: can't open file 'makeReadingsFile.py': [Errno 2] No such file or directory
occurs because there's no such file where you're telling it to look for one. Your second command looks to my eyes just like the first command:
Python makeReadingsFile.py eichstaett.net.xml test.readings.xml
Traceback (most recent call last):
File "makeReadingsFile.py", line 75, in <module>
import argparse
ImportError: No module named argparse
and you say that this is using the full address path, but since the given path is the same I think you must mean something like "when you change to the right directory". Anyway, the error message here is probably due to the fact you're using Python 2.6 or before: the argparse module was only introduced in Python 2.7.
I am encountering these errors frequently when I install python libraries and I'm wondering what I am doing wrong
the current example is the libchromaprint library
http://acoustid.org/chromaprint
I install it and everything, try to run the python example, get:
Traceback (most recent call last):
File "examples/fpwav.py", line 7, in <module>
import chromaprint
File "build/bdist.linux-x86_64/egg/chromaprint/__init__.py", line 24, in <module>
ImportError: couldn't find libchromaprint
and then when I check:
find /usr/local/lib/libch*
/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.0
/usr/local/lib/libchromaprint.so.0.1.3
what am I doing wrong?
Python does not use your usual library path. The chromaprint you're looking for should be somewhere like /usr/lib/pymodules/python2.6.
From the python interpreter do:
>>> import sys
>>> sys.path
This will show you the directories python searches for a module.