Installed the NumPy library, ran the elementary code from the tutorial, for example

import numpy as np a = np.array([0, 1, 2, 3, 4, 5]) print(a.ndim) print(a.shape) 

everything worked correctly after trying to run

 import timeit normal_py_sec = timeit.timeit('sum(x*x for x in range(1000))', number=10000) naive_np_sec = timeit.timeit( 'sum(na*na)', setup="import numpy as np; na=np.arange(1000)", number=10000) good_np_sec = timeit.timeit( 'na.dot(na)', setup="import numpy as np; na=np.arange(1000)", number=10000) print("Normal Python: %f sec" % normal_py_sec) print("Naive NumPy: %f sec" % naive_np_sec) 

gave an error. Now, every run of any code using NumPy crashes on the very first line of import, yielding

 Traceback (most recent call last): File "/home/oksana/PycharmProjects/machine_learning/ch_1.py", line 1, in <module> import numpy as np File "/usr/lib64/python3.4/site-packages/numpy/__init__.py", line 142, in <module> from . import add_newdocs File "/usr/lib64/python3.4/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/usr/lib64/python3.4/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/usr/lib64/python3.4/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/usr/lib64/python3.4/site-packages/numpy/core/__init__.py", line 58, in <module> from numpy.testing.nosetester import _numpy_tester File "/usr/lib64/python3.4/site-packages/numpy/testing/__init__.py", line 10, in <module> from unittest import TestCase File "/usr/lib64/python3.4/unittest/__init__.py", line 59, in <module> from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf, File "/usr/lib64/python3.4/unittest/case.py", line 7, in <module> import logging File "/usr/lib64/python3.4/logging/__init__.py", line 85, in <module> _startTime = time.time() AttributeError: 'module' object has no attribute 'time' 

Reinstalling via pip3 and yum did not help. Checked in Python 2, there are no problems. The newcomer to Python itself, I will be very grateful for the help.

Closed due to the fact that off-topic participants insolor , fori1ton , cheops , HamSter , aleksandr barakin 27 Oct '16 at 11:33 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - insolor, fori1ton, cheops, HamSter, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • In the subject of the question you specified Python 3.5 and in Traceback: python3.4 - are you sure that everything is in order with the environment (UNIX environment)? - MaxU
  • one
    The English-speaking SO had a similar question ( link ). - extraenough
  • I apologize, confused, on windows just 3.5, here 3.4 - See
  • Yes, it seems extraenough is right (a), only in your case it is not standard (i.e., your) time.py ... - MaxU

1 answer 1

figured out, the problem is that I called the second file time.py

  • one
    This is a common mistake. It is better not to give names to global modules that conflict with the standard library, another example . To prevent python from importing from the current directory, you can run it as python -I . - jfs