I know this question has been asked many times, but I couldn't manage to solve it on my own. So please bear with me.
Traceback (most recent call last):
File "/Users/someone/Desktop/eclipse/plugins/org.python.pydev_2.6.0.2012062818/pysrc/pydevd.py", line 3, in <module>
import pydev_imports
File "/Users/someone/Desktop/eclipse/plugins/org.python.pydev_2.6.0.2012062818/pysrc/pydev_imports.py", line 14, in <module>
from _pydev_SimpleXMLRPCServer import SimpleXMLRPCServer
File "/Users/someone/Desktop/eclipse/plugins/org.python.pydev_2.6.0.2012062818/pysrc/_pydev_SimpleXMLRPCServer.py", line 116, in <module>
import BaseHTTPServer
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 81, in <module>
import mimetools
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
echo $PATH gave me this. /Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
My goal is to setup an IDE that gives me code completion and breakpoint debug(like java, so that I can debug it line by line). I've read many posts here, but still haven't find a solution to it. Can anyone point to the right direction? Thanks in advance.
Edit:
I upgraded python to 2.7.3 because i couldn't select the interpreter in eclipse preferences.
Take a look at this link. All you need to do is make a proper configuration of your interpreter.
If it doesn't help, you should take a look at another one (the second one is about urandom module, whilst the first one about pydev configuration).
Related
I have Django app on hosting which has been running since June last year. I forgot to buy credits and so my hosting provider freezed my app. I bought new credits but I does not start. I simply get: "502 Bad Gateway".
I checked the logs, and in python.log found possible problem. Here is the traceback:
Traceback (most recent call last):
File "/srv/venv/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 10, in <module>
from gunicorn.app.base import Application
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn import util
File "/srv/venv/lib/python3.5/site-packages/gunicorn/util.py", line 12, in <module>
import pkg_resources
File "/srv/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 26, in <module>
import zipfile
File "/opt/python/lib/python3.5/zipfile.py", line 9, in <module>
import importlib.util
File "/srv/venv/lib/python3.5/importlib/util.py", line 7, in <module>
from ._bootstrap_external import MAGIC_NUMBER, _BACKCOMPAT_MAGIC_NUMBER
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
As far as I know there weren't any changes prior to this problem. Moreover I cannot find similar issues here on SO or elsewhere on the net.
importlib should be part of Python 3 so I thought I could try commenting out the import from "/opt/python/lib/python3.5/zipfile.py" but I don't have write permissions on the server.
I also tried recreating the venv which did not help. Same with switching Python runtime to either 3.4 or 3.6 in hosting's administration.
I am new to Python and am trying to use anaconda to do some data analysis. I am using Python 3.6.2 along with the geany text editor.
First, I'm trying to execute a file call panda.py which only contains import pandas as dp.
When I configure geany with a working directory of C:\Users\Anaconda3\python, I get the following error:
Traceback (most recent call last):
File "panda.py", line 1, in <module>
import pandas as dp
File "C:\Users\Anaconda3\lib\site-packages\pandas\__init__.py", line 13, in <module>
__import__(dependency)
File "C:\Users\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\_internal.py", line 18, in <module>
from .numerictypes import object_
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 962, in <module>
_register_types()
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 958, in _register_types
numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'
The same error also occurs when I enter the following at the command prompt:
C:\Users\Anaconda3\python.exe C:\Users\Documents\python_work\panda.py
However, if I execute C:\Users\David\Anaconda3\python.exe and then enter import pandas as dp in the REPL, it appears to load without error.
Any idea how I can fix this so I can use anaconda with geany?
[SOLVED] John below ask if I had a file called numbers.py in my directory which made me realize I named an exercise I previously did as numbers.py. Once I removed it, the error went away (I tested it further by adding a file with the name again and the error returned).
I'm new to the stack over flow community. Let me know if there's anything else I need to do to close out this question.
Also thanks to chb for the edits to my original question the format looks much easier to read.
Disclaimer: python on windows is not something I know about
You know that C:\Users\David\Anaconda3\python.exe when run standalone knows how to import pandas, so your setup is fine - you have everything installed that you need, and in the correct locations.
Given that, you can look at two issues: gearny setup, and general setup. I noticed that python and pandas is installed under C:\Users\Anaconda3, while your program is under C:\Users\Documents\python_work, and we also have C:\Users\David - could it be permissions issues?
I'm fairly new to Python, and I don't understand what is going on here.
C:\Users\Mike\Desktop>storytext testGui.py
Traceback (most recent call last):
File "C:\Python25\Scripts\storytext.py", line 19, in <module>
from storytext.cmdline import main
File "C:\Python25\lib\site-packages\storytext-3.7-py2.5.egg\storytext\cmdline.py", line 3, in <module>
import scriptengine, definitions
File "C:\Python25\lib\site-packages\storytext-3.7-py2.5.egg\storytext\scriptengine.py", line 4, in
<module>
import recorder, replayer
File "C:\Python25\lib\site-packages\storytext-3.7-py2.5.egg\storytext\recorder.py", line 6, in <module>
from replayer import ReplayScript
File "C:\Python25\lib\site-packages\storytext-3.7-py2.5.egg\storytext\replayer.py", line 5, in <module>
from threading import Thread, Timer
File "C:\Python25\lib\threading.py", line 13, in <module>
from collections import deque
ImportError: No module named collections
Ok, no Module named collections. Indeed, when I search my python25 folder for collections, it's not there. I've read that it's located at Modules/_collectionsmodule.c, which I also can't find.
The kicker to the whole thing is that I can import collections from the interpreter, and I can from threading import Time, Timer in the interpreter.
I do have both python 2.5 and 2.6 on this machine, and it's running Windows 7.
Can anyone point me in the right direction?
I'm currently working on a Python/Twisted project which is to be distributed and tested on Planetlab. For some reason my code was working on friday and now that I wanted to test a minor change it refuses to work at all:
Traceback (most recent call last):
File "acn_a4/src/node.py", line 6, in <module>
from twisted.internet.protocol import DatagramProtocol
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/__init__.py", line 18, in <module>
from twisted.python import compat
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/python/compat.py", line 146, in <module>
import operator
File "/home/cdecker/dev/acn/acn_a4/src/operator.py", line 7, in <module>
File "/home/cdecker/acn_a4/src/node.py", line 6, in <module>
from twisted.internet.protocol import DatagramProtocol
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/internet/protocol.py", line 20, in <module>
from twisted.python import log, failure, components
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/python/log.py", line 19, in <module>
from twisted.python import util, context, reflect
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/python/util.py", line 5, in <module>
import os, sys, hmac, errno, new, inspect, warnings
File "/usr/lib/python2.5/inspect.py", line 32, in <module>
from operator import attrgetter
ImportError: cannot import name attrgetter
And since I'm pretty new to python I have no idea what could have caused this problem.
All suggestions are welcome :-)
One of your own files, /home/cdecker/dev/acn/acn_a4/src/operator.py shadows Python's builtin operator module. You should rename your own operator.py to something else.
You can see the problem here:
File "/usr/lib/python2.5/site-packages/Twisted-10.0.0-py2.5-linux-i686.egg/twisted/python/compat.py", line 146, in <module>
import operator
File "/home/cdecker/dev/acn/acn_a4/src/operator.py", line 7, in <module>
Twisted tries to import operator but Python loads one of your own modules.
To prevent stuff like that in the future you should probably not add your src folder to the PYTHONPATH like that. Create a package instead, so that your own files appear as myproject.mymodule and can't shadow builtins.
ImportError is raised on import statement when a name cannot be imported, because module or package or name doesn't exists. In your case attrgetter doesn't exists in operator module.
The first idea is that you define a module called operator in the project's main directory. Modules, or packages, are searched following sys.path order, if you define a module with the same name in your main directory, you are hiding all others module with the same name in the search path.
In my script, I've imported urrlib2 and the script was working fine. After reboot, I get the following error:
File "demo.py", line 2, in <module>
import urllib2
File "/usr/lib/python2.6/urllib2.py", line 92, in <module>
import httplib
File "/usr/lib/python2.6/httplib.py", line 78, in <module>
import mimetools
File "/usr/lib/python2.6/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
ImportError: cannot import name Random
And when I do import random separately, it works fine. Any ideas what might be wrong?
I'm using ubuntu 9.10 (up to date). thanks
The usual answer is that you've got a file called random.py in the current directory when the script is running. tempfile would be accidentally importing that random and not the stdlib random module.
Check that random is the stdlib's module and not some arbitrary module with the same name from sys.path.
>>> inspect.getabsfile(random)