Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Troubles with numpy
#1
Hi all ! I installed twice numpy. Last time with "pip install --upgrade numpy". It installed numpy-1.14.4. But when I use it, it says it cannot handle multiarrays.
My question: is it preferable to 1. pip --upgrade numpy 2. pip install numpy ???
Reply
#2
Error:
File "<stdin>", line 1, in <module> File "C:\Users\Sylvain\numpy\__init__.py", line 142, in <module> from . import add_newdocs File "C:\Users\Sylvain\numpy\add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "C:\Users\Sylvain\numpy\lib\__init__.py", line 8, in <module> from .type_check import * File "C:\Users\Sylvain\numpy\lib\type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "C:\Users\Sylvain\numpy\core\__init__.py", line 26, in <module> raise ImportError(msg) ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control). Otherwise reinstall numpy. Original error was: cannot import name 'multiarray' Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control). Otherwise reinstall numpy. Original error was: cannot import name 'multiarray'
Reply
#3
(Jun-08-2018, 09:21 AM)sylas Wrote: C:\Users\Sylvain\numpy\
numpy folder should not be there at all.
How you mange to get it there i don't know.
If check pip what dos it point to?
C:\>pip -V
pip 10.0.1 from c:\python36\lib\site-packages\pip (python 3.6)
Then pip install numpy will install to 3.6 at that location.
>>> import numpy
>>>
>>> numpy.__file__
'C:\\Python36\\lib\\site-packages\\numpy\\__init__.py'
Even if i make a virtual environment and install numpy is always in site-packages\numpy
# Make
C:\bar
λ python -m venv my_env

# cd in
C:\bar
λ cd my_env

# Activate
C:\bar\my_env
λ C:\bar\my_env\Scripts\Activate
(my_env) C:\bar\my_env

# Check pip
λ pip -V
pip 9.0.1 from c:\bar\my_env\lib\site-packages (python 3.6)

# Install
(my_env) C:\bar\my_env
λ pip install numpy
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/6c/49/2bcf9d0484b33a6d7c5312121344a190d4a3d5f7826fcb3480cb62109073/numpy-1.14.4-cp36-none-win32.whl (9.8MB)
    100% |████████████████████████████████| 9.8MB 125kB/s
Installing collected packages: numpy
Successfully installed numpy-1.14.4

# Test
(my_env) C:\bar\my_env
λ python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
>>> numpy.__file__
'C:\\bar\\my_env\\lib\\site-packages\\numpy\\__init__.py'
Reply
#4
I had copied numpy in "Users\Sylvain" because i had this error message. Of course, following your indication I deleted the numpy in "Users\Sylvain"
Error:
λ ptpython >>> import numpy Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'numpy' No module named 'numpy'
Reply
#5
Now it's okay,you need of course to install it.
# Check
C:\Users\Tom
λ pip -V
pip 10.0.1 from c:\python36\lib\site-packages\pip (python 3.6)

# Install 
C:\Users\Tom
λ pip install numpy --upgrade
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/6c/49/2bcf9d0484b33a6d7c5312121344a190d4a3d5f7826fcb3480cb62109073/numpy-1.14.4-cp36-none-win32.whl
mypy 0.560 has requirement psutil<5.5.0,>=5.4.0, but you'll have psutil 5.3.1 which is incompatible.
Installing collected packages: numpy
Successfully installed numpy-1.14.4

# Test that it work
C:\Users\Tom
λ ptpython
>>> import numpy

>>> numpy.__version__
'1.14.4'
Reply
#6
There is a long time it is installed(successfully) at C:\python35\\lib\site-packages. And its version is: 1.14.4
Strange enough python cannot find it !

At last found that there is no trouble if I use "python" instead of "ptpython". Look at this:
λ python                                                                              
ActivePython 3.5.4.3504 (ActiveState Software Inc.) based on                          
Python 3.5.4 (default, Dec 15 2017, 14:24:56) [MSC v.1900 64 bit (AMD64)] on win32    
Type "help", "copyright", "credits" or "license" for more information.                
>>> import numpy                                                                      
>>> numpy.__file__                                                                    
'C:\\Python35\\lib\\site-packages\\numpy\\__init__.py'                                
>>>                                                                                   
Reply
#7
For 3.6 as you should use.
Python 3.6 and pip installation under Windows
The it will work as i posted,i do have 2.7,3.4,3.5 ect.
3.6 is the main version set in Windows Path(as tutorial show how to under install).

Then it look like this from C:\.
So anywhere from cmd/cmder,pip and python always point to 3.6
λ python -c "import sys; print(sys.executable)"
C:\python36\python.exe

C:\
λ pip -V
pip 10.0.1 from c:\python36\lib\site-packages\pip (python 3.6)
Using other version can use py.exe,that 3.6 install in Windows folder.
C:\
λ py -2.7 -V
Python 2.7.9

C:\
λ py -3.5 -V
Python 3.5.2
Reply
#8
Another remark: ptpython version is: 3.6.4
Reply
#9
(Jun-08-2018, 05:40 PM)sylas Wrote: Another remark: ptpython version is: 3.6.4
It dos not matter make sure installasjon is okay first,follow link on how to install 3.6.
Restart Pc.
Then as posted test that python and pip point to 3.6.

Then in future will all install point to 3.6.
pip install ptpython
pip install numpy --upgrade
ect... will install to 3.6
Reply
#10
I am sure python 3.6 is installed. Why pip speaks of python 3.5 instead of 3.6 ??
C:\
λ pip -V
pip 10.0.1 from c:\python35\lib\site-packages\pip (python 3.5)

C:\                                                            
λ py -3.6 -V                                                   
Python 3.6.4                                                   
                                                               
C:\                                                            
λ pip -V                                                       
pip 10.0.1 from c:\python35\lib\site-packages\pip (python 3.5) 
You see I have 3.6.4, but with pip -V, it comes back to 3.5. What shall I do for having 3.6 ??
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 538 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,600 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,976 Apr-09-2019, 04:54 PM
Last Post: PhysChem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020