Installing numpy on Windows 7 and python 3.x - python

I can't install a library, or at least numpy. I have a Windows 7 Home Premium 64 bits and Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32.
I go to their website to Getting Numpy which sends me to SourceForge where I download the latest (I have already update my python to 3.3) and open and install it. Apparently successfully. But when I open python and type import numpy I get:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
File "C:\Python33\lib\site-packages\numpy\__init__.py", line 168, in <module>
from . import add_newdocs
File "C:\Python33\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python33\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python33\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python33\lib\site-packages\numpy\core\__init__.py", line 6, in <module>
from . import multiarray
ImportError: DLL load failed: %1 no es una aplicación Win32 válida.
The last line it means that %1 it is not a valid Win32 program.
Tere is a similar question here where they point the OP to the Windows Installer. So I download the zip file and decompress it. And now?
Somewhere I found that it should be in the Lib folder and then run the setup.py file. I tried again to import numpy but again the same error.
I found here some instructions, but the first step it is already different, my error message it is not the same, is the same as step 6. But then the step 8 is to install the 32-bits system after uninstalling numpyand Python, but there is no 32 version for Python 3.3 (or at least not that I understand). What should I do?
So I reinstall the python 3.3 I already had.
And this time when I type from numpy import * or import numpy I don't get an error but when I try to make an array I do:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
type(array([1,6,3,7]))
NameError: name 'array' is not defined
Another way I found is from this source with python 3.3 which leads me to another unofficial page where I download the numpy-MKL-1.8.0.win32-py3.3 file following the steps of the blog. But still the same error of NameError.
I didn't restart the computer yet...
I forgot something else or I miss one step?

So, after rebooting it seems to work well. I post here what worked for me
Install python for just for me. Download from here the library, install the latest (or the version you want) with 32 bites even if the computer is 64 bites and restart the computer.

Christophe Gohlke maitains an extensive collection of windows binaries for various python libraries including numpy. Have you tried here?
/www.lfd.uci.edu/~gohlke/pythonlibs/

Related

Error importing sklearn in python 3.7: DLL load failed: The network path was not found

When I import sklearn in python shell, I got the following error
ImportError: DLL load failed: The network path was not found.
Here is python version: 3.7.3 64 bit
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
My PC is allocated to students by the university, which is Win10 Edu, 64 bit OS. And I am the administrator
When I was using 32 bit Python, every thing was fine. I changed to 64 bit Python last week because I need to use tensorflow. And then I have problem with sklearn.
Here are the full error message
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import sklearn
File "C:\Program Files\Python37\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "C:\Program Files\Python37\lib\site-packages\sklearn\base.py", line 14, in <module>
from .utils.fixes import signature
File "C:\Program Files\Python37\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
from .fixes import _Sequence as Sequence
File "C:\Program Files\Python37\lib\site-packages\sklearn\utils\fixes.py", line 85, in <module>
from scipy.special import boxcox # noqa
File "C:\Program Files\Python37\lib\site-packages\scipy\special\__init__.py", line 641, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The network path was not found.
I tried pip list in cmd prompt and I found sklearn (version 0.0)/scikit-learn(version 0.20.3) are both installed.
I searched a lot, but I didn't find anyone having the same problem. I found this question: Error importing sklearn, looks like a different problem to me.
I have reinstall Python, reinstall sklearn (both pip and using wheel), NumPy and SciPy. I unistalled pycharm and anaconda. I also uninstall the Python 2.7 in my pc. None of these worked. Any suggestions are welcomed!
I faced the exact same error. it seems like sklearn installs wrong version of scipy. you should install sklearn first and then install scipy 1.3.0rc1 and numpy+mkl from Christoph Gohlke windows binaries.
https://www.lfd.uci.edu/~gohlke/pythonlibs/

NLTK ImportError: DLL load failed: The specified module could not be found

I am trying to import nltk to my project. I have tried installing it through many different ways and they all lead to the same outcome.
I tried installing it through the lightbulb on PyCharm, I tried installing the module through the project settings, I tried installing nltk through conda -install nltk. I don't understand why I get this error:
import nltk
nltk.download()
C:\Users\Orestis\PycharmProjects\LimeExamples\venv\Scripts\python.exe
C:/Users/Orestis/PycharmProjects/LimeExamples/hate_tweets.py
Traceback (most recent call last):
File "C:/Users/Orestis/PycharmProjects/LimeExamples/hate_tweets.py", line 1, in <module>
import nltk
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\__init__.py", line 152, in <module>
from nltk.stem import *
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\stem\__init__.py", line 29, in <module>
from nltk.stem.snowball import SnowballStemmer
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\stem\snowball.py", line 32, in <module>
from nltk.corpus import stopwords
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\corpus\__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\corpus\reader\__init__.py", line 105, in <module>
from nltk.corpus.reader.panlex_lite import *
File "C:\Users\Orestis\PycharmProjects\LimeExamples\venv\lib\site-packages\nltk\corpus\reader\panlex_lite.py", line 15, in <module>
import sqlite3
File "C:\Users\Orestis\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Users\Orestis\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
Its not a nltk problem but rather a sqlite3 problem. Error shows that the required sqlite dll file is not found in your system.
A simple workaround solution would be to download the required dll file as per your system configuration windows/linux x64 or x32 accordingly from here and place them at: Anaconda\DLLs directory.
Make sure Anaconda\DLLs is added to your path variables as well.
Even though the nltk errors are huge, SQLite plays a fair part. sqlite.dll file might be located somewhere, so find it and place it in dlls folder. If there is no such file, download and place it in. It worked for me.
For anyone that has the same problem in the future by following Pavel Karateev's advice I was able to solve this. I created a normal conda environment and installed all the packages through anaconda prompt by using e.g. conda -install nltk in the conda virtual environment I had created.
From what I understand the problem was that I had created a venv with PyCharm UI using anaconda as a base which is a big mistake!
Other locations for the dll from Rohit's explanation that you might try:
C:\Users\MYUSERNAME\Anaconda3\DLLs
Or: C:\ProgramData\Anaconda3\DLLs)
If you want to know which python location your script is running from run this in your script:
import sys
sys.path
The easy and effective way is to download the sqlite3 dll from https://www.sqlite.org/download.html. Download the 64 or 32 bit depending on the OS and paste it on C:\Users\USER_NAME\anaconda3\DLLs. It worked for me
The combination of answers from #user5099519 and #NIGHT_SHADE worked for me.
Problem statement: There was no sqlite3 in the DLL folder.
Solution:
Step 1: Identify where the DLL folder is. Activate your conda environment and type the following:
> python
Python 3.7.15 (default, Nov 24 2022, 18:44:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
This will return a list of multiple paths. You search for the term "DLL". For example, mine is 'C:\Users\username\anaconda3\envs\conda-env\DLLs'.
Step 2: Download sqlite3 dll from https://www.sqlite.org/download.html then extract it into the DLL folder. For example, as a 64-bit Windows user, in Precompiled Binaries for Windows, I selected sqlite-dll-win64-x64-3400000.zip.
import nltk
nltk.download('all')
You need to specified the module. Also see How do I download NLTK data?

Python Cryptography Error cannot import name certificate_transparency

trying to run a pymodbus tcp server and im getting this stack trace... at a total loss here so any help is appreciated. Thanks!
Traceback (most recent call last):
File "Worrking_ModbusJ1939Bridge.py", line 12, in <module>
from pymodbus.server.async import StartTcpServer
File "build/bdist.linux-armv7l/egg/pymodbus/server/async.py", line 18, in <module>
File "build/bdist.linux-armv7l/egg/pymodbus/internal/ptwisted.py", line 5, in <module>
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/manhole_ssh.py", line 14, in <module>
from twisted.conch.ssh import factory, session
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/factory.py", line 18, in <module>
from twisted.conch.ssh import (_kex, transport, userauth, connection)
File "/usr/local/lib/python2.7/dist packages/twisted/conch/ssh/transport.py", line 345, in <module>
class SSHTransportBase(protocol.Protocol):
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 469, in SSHTransportBase
supportedCiphers = _getSupportedCiphers()
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 335, in _getSupportedCiphers
backend=default_backend(),
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 16, in <module>
from cryptography import utils, x509
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
I was using pip 7 and got the same problem. Upgrading to pip 9 solved it. I'm not sure about the cause.
Via: https://github.com/micheloosterhof/cowrie/issues/618
I've been hitting this while attempting to update Python Cryptography for Solaris 11.4, using the https://github.com/oracle/solaris-userland/ build system. A "simple" update to pip isn't an option for me, that's not how we do things.
I eventually figured out the solution: I'd built the package incorrectly.
Cryptography 2.1.4 depends on cffi > 1.7. Both of these packages have new deliverable bits compared to the versions we were shipping.
Failing to update the package manifest to correctly track the new files results in both cffi and cryptography being unable to import symbols that the current versions depend upon.
[A very big thankyou to Alex Gaynor in #cryptography-dev who set me on the right path to figuring this out].
$ python2.7
Python 2.7.14 (default, Jan 31 2018, 05:35:05) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.bindings._openssl import ffi, lib
>>> from cryptography.x509 import certificate_transparency
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/vendor-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
If you build cryptography and look at what it delivers, you will find that there is in fact a file (shipped on Solaris as /usr/lib/python-$(PYVER)/vendor-packages/cryptography/x509/certificate_transparency.py) - and if that file isn't in the rest of the hierarchy then you end up with exactly this ImportError.
it works for me (problems with paramiko):
https://pypi.python.org/pypi/ctutlz/0.7.0
pip install --process-dependency-links ctutlz
I had a similar issue on RHEL 6.7 x86_64 running Python 2.7.8 with an old version of pip (1.4.1)
It was because I had been installing the "cp27m" builds rather than "cp27mu" builds.
With the old pip 1.4.1 build, it did not complain installing the cp27m builds.
Whereas when upgrading pip to 9.0.3, it spat out the true error ...
(bmcs2)bash-4.1$ pip install cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl
cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl is not a supported wheel on this platform.
(bmcs2)bash-4.1$ pip install cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl
cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl is not a supported wheel on this platform.
The "ImportError: cannot import name certificate_transparency" was resolved using the "cp27mu" builds. When using the "cp27mu" build, both the pip 1.4.1 and pip 9.0.3 versions worked fine.
cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl versus cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl
cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl versus cryptography-2.1.3-cp27-cp27mu-manylinux1_i686.whl
More info here:
https://www.python.org/dev/peps/pep-0513/#ucs-2-vs-ucs-4-builds
I think this more like a paramiko issue not pip. Upgrading pip didn't solve this in my environment i had to downgrade my paramiko version to a version that does not have a libffi dependency, this worked for me:
pip2.7 install paramiko==1.17.0
this issue is related to: https://github.com/paramiko/paramiko/issues/1401
I got this error while trying to run Scrapy in AWS Lambda, deploying with a zip file.
I followed the instructions in https://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html, which basically instructs you to start an Amazon Linux EC2 instance, install the requirements and build the zip from it.
After setting up the whole thing, the first package I created still gave me the same error, but I realised that was because a hidden folder, .libs_cffi_backend, was missing from the zip file. That folder contains a .so file that if not present causes ImportError. After forcefully including it, it worked.

Import NumPy gives me ImportError: DDL load failed: The specified procedure could not be found?

My Environment: Win10 64 bits, Python 3.6 and I use pip install to install NumPy instead of Anaconda. NumPy version: 1.13.0
I have seen several people posted similar questions, but most of them are using Python 2.7. The closest solution I have seen so far is: https://github.com/ContinuumIO/anaconda-issues/issues/1508 and https://github.com/numpy/numpy/issues/9272. But it seems they did not solve it in the end and the people who posted it are using Python 2.7. Therefore, I was wondering if someone can help me about this. My error log is below. Any help would be appreciated.
C:\Users\Kevin>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "D:\Python3.6\lib\site-packages\numpy\core\__init__.py", line 16, in
<module>
from . import multiarray
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python3.6\lib\site-packages\numpy\__init__.py", line 142, in
<module>
from . import add_newdocs
File "D:\Python3.6\lib\site-packages\numpy\add_newdocs.py", line 13, in
<module>
from numpy.lib import add_newdoc
File "D:\Python3.6\lib\site-packages\numpy\lib\__init__.py", line 8, in
<module>
from .type_check import *
File "D:\Python3.6\lib\site-packages\numpy\lib\type_check.py", line 11, in
<module>
import numpy.core.numeric as _nx
File "D:\Python3.6\lib\site-packages\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: DLL load failed: The specified procedure could not be
found.
You should go with doing a clean install of numpy. Just don't go with the traditional way but download the wheel file instead. You can get the wheel file from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ . Download this file- numpy‑1.13.0+mkl‑cp36‑cp36m‑win_amd64.whl and install this wheel using pip. Check by importing numpy from shell.
If you do not want to bother with finding the wheel file just uninstall numpy and install an old version:
pip3 uninstall numpy
pip3 install 'numpy<1.13'
Uninstall NumPy and after that type:
pip3 install numpy==1.12

import healpy unicode error with enthought canopy python

I'm running Ubuntu 12.10
Enthought Canopy Python 2.7.6 64 bit
I have succesfully installed healpy using the direct Healpix configuration as well as using sud pip install healpy, and have made sure PYTHONPATH was set accordingly in the bashrc.
When I try to import healpy I get this unicode incomparability related error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/healpy/__init__.py", line 47, in <module>
from sphtfunc import (anafast, map2alm,
File "/usr/local/lib/python2.7/dist-packages/healpy/sphtfunc.py", line 26, in <module>
import _sphtools as _sphtools
ImportError: /usr/local/lib/python2.7/dist-packages/healpy/_sphtools.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
Related issues have solutions that require rebuilding. I'm not sure how to go about doing this, and was wondering if there is an easier solution. Thank you in advance for any assistance.

Categories