im trying to import matplotlib.pyplot, here is my code:
import matplotlib.pyplot as plt
squares = [1, 4, 9, 16, 25]
plt.plot(squares)
plt.show()
I'm using the Geany IDE under Ubuntu 16.04.03, and i'm getting the
following errormessage
[1, 2, 3, 4, 5]
Traceback (most recent call last):
File "mpl_squares.py", line 1, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.5/dist-packages/matplotlib/__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "/usr/local/lib/python3.5/dist-packages/matplotlib/cbook.py", line 32, in <module>
import numpy as np
File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "/usr/local/lib/python3.5/dist-packages/numpy/core/_internal.py", line 18, in <module>
from .numerictypes import object_
File "/usr/local/lib/python3.5/dist-packages/numpy/core/numerictypes.py", line 962, in <module>
_register_types()
File "/usr/local/lib/python3.5/dist-packages/numpy/core/numerictypes.py", line 958, in _register_types
numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'
This error occurs only when i'm using the Geany IDE, when i'm running the
code in the terminal it works fine.
Has somebody an idea what's wrong with Geany?
Thanks in advance!
With Geany your working directory is different. I'm thinking it's the same as here:
https://www.reddit.com/r/learnpython/comments/5pvdjk/module_object_has_no_attribute_integral/
Related
I use python3.6.0 (googletrans3.0). I import googletrans3.0.
Traceback (most recent call last):
File "C:\Python\Python36-32\traduction essai.py", line 3, in <module>
import googletrans
File "C:\Python\Python36-32\lib\site-packages\googletrans\__init__.py", line 6, in <module>
from googletrans.client import Translator
File "C:\Python\Python36-32\lib\site-packages\googletrans\client.py", line 10, in <module>
import httpcore
File "C:\Python\Python36-32\lib\site-packages\httpcore\__init__.py", line 2, in <module>
from ._async.connection_pool import AsyncConnectionPool
File "C:\Python\Python36-32\lib\site-packages\httpcore\_async\connection_pool.py", line 4, in <module>
from .._backends.auto import AsyncLock, AsyncSemaphore, AutoBackend
File "C:\Python\Python36-32\lib\site-packages\httpcore\_backends\auto.py", line 4, in <module>
import sniffio
File "C:\Python\Python36-32\lib\site-packages\sniffio\__init__.py", line 10, in <module>
from ._impl import (
File "C:\Python\Python36-32\lib\site-packages\sniffio\_impl.py", line 1, in <module>
from contextvars import ContextVar
File "C:\Python\Python36-32\lib\site-packages\contextvars\__init__.py", line 4, in <module>
import immutables
File "C:\Python\Python36-32\lib\site-packages\immutables\__init__.py", line 18, in <module>
from ._protocols import MapKeys as MapKeys
File "C:\Python\Python36-32\lib\site-packages\immutables\_protocols.py", line 6, in <module>
from typing import NoReturn
ImportError: cannot import name 'NoReturn'
image
I'm trying to run a python game source I made, but everytime I do "python Login.py" I get this whole traceback:
Traceback (most recent call last):
File "Login.py", line 1, in <module>
from Houdini.HoudiniFactory import HoudiniFactory
File "/var/xsource/Houdini/HoudiniFactory.py", line 18, in <module>
from Houdini.Crumbs import retrieveItemCollection, retrieveRoomCollection, \
File "/var/xsource/Houdini/Crumbs/__init__.py", line 45, in <module>
from Houdini.Crumbs.Room import RoomSchema, RoomCollection
File "/var/xsource/Houdini/Crumbs/Room.py", line 6, in <module>
from Houdini.Handlers.Games.Table import leaveTable
File "/var/xsource/Houdini/Handlers/Games/__init__.py", line 4, in <module>
from Houdini.Handlers.Play.Moderation import cheatBan
File "/var/xsource/Houdini/Handlers/Play/Moderation.py", line 4, in <module>
from Houdini.Data.Penguin import Penguin
File "/var/xsource/Houdini/Data/__init__.py", line 5, in <module>
from alchimia.engine import TwistedEngine
File "/home/ubuntu/.local/lib/python2.7/site-packages/alchimia/__init__.py", line 3, in <module>
from alchimia.strategy import TWISTED_STRATEGY
File "/home/ubuntu/.local/lib/python2.7/site-packages/alchimia/strategy.py", line 3, in <module>
from sqlalchemy.engine.strategies import DefaultEngineStrategy
ImportError: cannot import name DefaultEngineStrategy
If someone knows how to fix this please let me know, thank you so much!
I'm using Python 3.6 in Ubuntu 16.04.
From this very simple program:
import pandas_datareader.data as web
import datetime
amzn = web.DataReader("AMZN", "yahoo", datetime(2000,1,1), datetime(2015,1,1))
I get this very impressive error list:
Traceback (most recent call last):
File "/SAT/time_series.py", line 1, in <module>
import pandas_datareader.data as web
File "/anaconda/lib/python3.6/site-packages/pandas_datareader/__init__.py", line 3, in <module>
from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
File "/anaconda/lib/python3.6/site-packages/pandas_datareader/data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
File "/anaconda/lib/python3.6/site-packages/pandas_datareader/google/daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
File "/anaconda/lib/python3.6/site-packages/pandas_datareader/base.py", line 3, in <module>
import numpy as np
File "/anaconda/lib/python3.6/site-packages/numpy/__init__.py", line 146, in <module>
from . import add_newdocs
File "/anaconda/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/anaconda/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/anaconda/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/anaconda/lib/python3.6/site-packages/numpy/core/__init__.py", line 72, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/anaconda/lib/python3.6/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/anaconda/lib/python3.6/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/anaconda/lib/python3.6/unittest/main.py", line 4, in <module>
import argparse
File "/SAT/argparse.py", line 1
if len(sys.argv) > 1:
^
SyntaxError: invalid syntax
I've really now idea what is causing this error other than it's occurring when the program tries to import pandas_datareader.
I am new to the data_reader but I'm pretty sure the import command is syntactically correct.
Can anyone suggest what the problem is?
I think you have shadowed Python module argparse with your own /SAT/argparse.py.
/anaconda/lib/python3.6/unittest/main.py in line 4 tries to import argparse (the standard Python module), but your module (which has an error len(sys.argv) > 1:) jumps in first.
Try to rename /SAT/argparse.py to /SAT/my_argparse.py
PS try to name your own scripts and directories differently so that they don't shadow stardard Python modules
Try this:
import datetime
import pandas_datareader.data as web
amzn = web.DataReader("AMZN", "yahoo", datetime.datetime(2000,1,1), datetime.datetime(2015,1,1))
I have been trying to import theano.tensor in my code.
I have used theano.tensor before. All of my previous code importing theano.tensor works perfectly in my machine. Now I am trying to write another script importing the tensor from theano and I am getting the following exception.
Traceback (most recent call last):
File "code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/__init__.py", line 52, in <module>
from theano.gof import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/__init__.py", line 56, in <module>
from theano.gof.opt import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/opt.py", line 11, in <module>
import pdb
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/localtmp/saikat/CovInfo/Closure/code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/__init__.py", line 6, in <module>
from theano.tensor.basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/basic.py", line 17, in <module>
from theano.tensor import elemwise
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 13, in <module>
from theano import scalar
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/__init__.py", line 2, in <module>
from .basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/basic.py", line 25, in <module>
from theano import gof, printing
File "/anaconda3/lib/python3.5/site-packages/theano/printing.py", line 22, in <module>
from theano.compile import Function, debugmode, SharedVariable
File "/anaconda3/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
import theano.compile.mode
File "/anaconda3/lib/python3.5/site-packages/theano/compile/mode.py", line 77, in <module>
OPT_NONE = gof.Query(include=[], exclude=exclude)
AttributeError: module 'theano.gof' has no attribute 'Query'
I cannot find any plausible reason for this exception.
I guess i got your problem. See in the error log:
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
I believe there is another script called code.py in Theano which gets called from pdb.py when python interpreter executes your script which is also named as code.py. I am guessing python interpreter is mixing up these two scripts and executing the wrong one! You can change the filename and check whether the error disappear or not.
I am trying to run this simple code
import numpy as np
bmi = np.array([12,123,34])
print bmi
When I execute it however I get the following error:
Traceback (most recent call last):
File "sample10.py", line 1, in <module>
import numpy as np
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\core\__init__.py", line 21, in <module>
from . import function_base
File "C:\Users\Marc\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Any thoughts what might be causing this? When Im running
python --version
I get 2.7.11