Python as non admin? - python

Im trying to package Anaconda with Tensorflow and Keras on Windows 10 for a class in our labs environment which the labs computers do not have administrator access nor do the students for security reasons.
Problem few lines of code to test to see if the installation is working correctly only work when you launch python as administrator:
>>> import keras
c:\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 ==
np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
when running as non admin account:
>>> import keras
Traceback (most recent call last):
File "c:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: dynamic module does not define module export function (PyInit_multiarray)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "c:\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 2, in <module>
from . import np_utils
File "c:\Anaconda3\lib\site-packages\keras\utils\np_utils.py", line 6, in <module>
import numpy as np
File "c:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "c:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "c:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "c:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "c:\Anaconda3\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: dynamic module does not define module export function (PyInit_multiarray)

Related

numpy multicore error while using matplotlib

while i try to run a matplotlib example program it shows "Failed to import numpy multicore array".Then i upgrade the numpy version from 1.12 to 1.15 on both the python versions 2.7 and 3.5(in raspberry pi python 2.7 is a default version).
The code am using is:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
while running this code it show some different error that
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/hdg.py", line 1, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.5/dist-packages/matplotlib/__init__.py", line 141, in <module>
from . import cbook, rcsetup
File "/usr/local/lib/python3.5/dist-packages/matplotlib/cbook/__init__.py", line 33, in <module>
import numpy as np
File "/home/pi/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/pi/.local/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/pi/.local/lib/python3.5/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: libf77blas.so.3: cannot open shared object file: No such file or directory
how to overcome this one?

import arcpy in the VS Code terminal fails

I am trying to get arcpy to import in the vs code terminal (running python 2.7 as an arcgis install). It runs fine if I open a command window, initiate python, and import arcpy. It also works within the ArcGIS environment. This leads me to beloeve that the error below is inaccurate. Importing arcpy does not work at the VS Code terminal. How can I resolve this?
>>> import arcpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\__init__.py", line 20, in <module>
import numpy
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python27\ArcGIS10.6\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\ArcGIS10.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 path is invalid.

Error in checking sklearn version

I am onto practising ML using python and visited through this link.
I installed all of the packages mentioned in the link namely, scipy, numpy, matplotlib, pandas, sklearn and implemented the following code to check their respective versions and proper installation,
# scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))
but got the following error:
Traceback (most recent call last):
File "VersionCheck.py", line 19, in <module>
import sklearn
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
from ..utils.fixes import signature
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\fixes.py", line 144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .isolve import *
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.
To see a version of sklearn installed:
from sklearn import __version__
print(__version__)

numpy error when running Python script from cmd

I have a Python script which I want to start from cmd because I'm going to call it in a C# script.
The problem is, the code works fine in the IDE and when I call it from the Anaconda script but not when I call it from the regular cmd.
I'm calling the script with the following line:
$ python c:/Users/myname/pycharmProjects/testing/main.py
I get the following error message:
Traceback (most recent call last):
File "c:/Users/myname/pycharmProjects/testing/main.py", line 1, in <module>
import process
File "/cygdrive/c/Users/myname/pycharmProjects/testing/process.py", line 4, in <module>
import numpy as np
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/__init__.py", lin e 142, in <module>
from . import add_newdocs
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/cygdrive/c/Users/myname/pycharmProjects/testing/numpy/lib/type_check.py ", line 11, in <module>
import numpy.core.numeric as _nx
File "/cygdrive/c/Users/myname/pycharmProjects/testing/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
I have uninstalled and reinstalled numpy, but the error is still the same. I'm really confused why I it works via the Anaconda prompt, but not the cmd as I did set the PATH variable.
Any help is appreciated!

Unable to import python packages in Ubuntu (ImportError : undefined symbol)

I recently installed python on my Ubuntu 14.04. I downloaded tensorflow by pip.
When I tried to import tensorflow it said ImportError:No module named tensorflow.
Then I edited PYTHONPATH by adding /usr/local/lib/python2.7/dist-packages. Now when I try to import, it says
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 45, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I found here that 2 versions of python causes the conflict, but that didn't help. Any assistance will be appreciated. Thank you
Best way to install packages if you have more than one python installed is:
path_to_your_python_executable -m pip install package_name
This way, you can make sure that you have installed package for proper python.
And don't forget about sudo ;)

Categories