I have a question which is very similar to Import Error: No module named numpy but the answer to that question I do not believe would be appropriate for me, so I'm asking again.
This is my most recent effort after about six hours of trying to get modules to work in python (numpy is a dependency of something else), so I'm finally turning to SO. Part of efforts in the last six hours included installing the enthought distribution, as its large volume of libraries was highly advised for windows users. I've even thrown the location of numpy folder onto the path of environment variables just to exclude it as a possibility.
Windows, 64bit, Python 2.7
Since you are on windows, I highly recommend that you install ANACONDA. This way the environment variables are set automatically and you don't need to worry about anything else. There are many useful packages (e.g. numpy, sympy, scipy) which are bundled with anaconda.
Moreover, based on personal experience I can tell you that using pip on windows and compiling from source (you need visual studio) is a pain in the neck sometimes. That's why ANACONDA has been conceived.
Hope this helps.
For python versions > 3.4 ,do this
pip install numpy beacuse pip is python dependency which installs packages just like npm in js i.e. node.js
Related
I've scoured the internet without much luck of finding how to fix what I'm doing wrong. I think I have all the pieces to the puzzle and know what is wrong but I just don't know what I need to do to fix it.
I'm starting to think I have two installs of python and I'm not updating the install that's being used in VS code and the python install that I have updated is not properly setup in VS code. I have anaconda downloaded but I think the VS code python extension is the only one that is set up properly. If I use the anaconda prompt and follow what a number of posts/solutions detail
import pandas as pd
pd.__version__
I get 1.1.3 which I believe I updated the other day when trying to fix my issue. However, if I use the terminal in VS code and do the same thing, I get 1.0.5 (which is the pandas version that produces the issue I am dealing with... it messes with dates when plotting pandas df). I'm guessing this has something do to with anaconda not being set to PATH and VS code is using the extension instead of the anaconda download. To further back this up, if I select
Python 3.7.9 64-bit (conda) interpreter instead of Python 3.7.9 64-bit
and run code that typically works on the non-conda interpreter, I get the following:
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Users\user
\anaconda3\python.exe"
* The NumPy version is: "1.19.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
If what I suspect is the issue, then I'm a bit confused how I've been able to import and use packages such as pandas, matplotlib, and Numpy when using the non-conda interpreter.
Would someone be able to explain and steer me in the right direction?
The reason for getting two different versions of "pandas" is that the Python interpreter you are using is different. The "Python 3.7.9 64-bit" you use is the python interpreter (global environment) that you downloaded and installed, and the "Python 3.7.9 64-bit (conda)" is the Python interpreter that comes with Anaconda (conda environment).
According to the terminal information you provided, there is no dependent package "numpy" of "pandas" in a non-conda environment. It is recommended that you install the module "numpy" (pip install numpy). Usually, when the module "pandas" is installed, the terminal will automatically install the dependencies it needs. Therefore, you could also reinstall "pandas" in the VSCode global environment.
If you want to specify a certain version of the module "pandas", you could use "pip install pandas==1.1.3" to install version 1.1.3.
I just got a new computer, and I was installing some Python libraries. When I tried to install numpy, I got a message on the console saying numpy was already downloaded. I went into the library folder, and not only was numpy there, but scipy, matplotlib, and a bunch of other libraries as well. How is this possible, considering this computer is brand new? I had installed Python the previous evening, so does installing Python automatically install these libraries as well?
It depends on which Python package you install.
On any desktop oriented Linux distribution, installing the Python package will only install Python. And in practice, it is generally already installed.
On Windows (and perhaps OS X), you need to pick a Python bundle somewhere. Perhaps did you choose Anaconda, which AFAIK installs a lot of common Python libraries (as opposed to its light version Miniconda).
Python does not ship with these libraries unless you are using a pre-packaged distribution such as Anaconda.
If you copied your data from your previous computer to this one, you may have copied the python installation (and thereby the libraries you had installed before) in your appdata folder.
Another possibility is that you have install Anaconda, which is targeted especially at scientific things, and comes with numpy, scipy and some other things preinstalled.
Although this is not the place for these types of questions, yes, there is no need to install libraries, as most of the times when you download Python in a distribution, such as Anaconda, they are also included.
So after numerous attempts at installing NumPy, all seem to have gone well until I boot up PyCharm and import numpy. It throws the "Module not found" error with just a single line of code, being:
import numpy as numpy
It's getting fairly frustrating, after installing numpy through pip, downloading the .whl and manually installing it, and even somehow bricking my computer by repairing python 3.6. I've got no idea as to what I'm doing wrong. Help would be greatly appreciated.
Without knowing exactly what you have installed in your computer, it can be a bit tricky to troubleshoot it. However, you have to be aware that you can have multiple Python installations in your computer. It is quite common to have Python2.X and Python3.X side by side.
When you used pip to install numpy, you installed it for a specific Python interpreter (sometimes you have pip2 and pip3 in your system, for example). And then, when you use PyCharm, it may be grabbing the wrong Python interpreter. You can go to File/Settings/Project and you will find something like the window below:
You will see that you can choose your interpreter and it will give you the list of all installed packages. I suggest that you check that you have numpy listed.
Moreover, from the same window you can install the packages you need; just click on the green + sign at the right of the screen and search for numpy and follow the needed steps.
Pro Tip: You should definitely consider using virtual environments, which are entirely supported by PyCharm.
A remote server that I used for python development recently migrated to Ubuntu 14.04 and it has broken my numpy and scipy installation. I do not have root access and everything I have tried has resulted in failure. So far I have:
1) Tried to install numpy from source built with the system version of python. This gives a PyUnicodeUCS2_FromUnicode error which I believe is because the system version uses ucs4. As I do not have root access I do not know if there is anything I can do about this.
2) Tried to install numpy using pip. This gives an error saying that it cannot find the Python.h header file that is included in python-dev. Again, I have no root access so cannot install python-dev.
3) Tried to create a virtual environment and install a new version of python. Initially I got a httpsrequest import error which meant I couldn't use pip but I was able to install from source. However when I then installed scipy and tried to import a module, I got the error that a libgfortran library was not found.
I've spent the last day trying to find a solution to this but everything I try seems to encounter an error somewhere. I also don't want to have to install to much stuff (i.e. dependencies) in my home directory to get this to work as I only have a limited amount of space. Any ideas on how I could proceed?
Have you considered using an 'all-in-one' package for scientific computing with Python, such as
Canopy
Anaconda
Miniconda
Have you tried downloading Sage? You can just use it as an Ipython system if you want (sage -ipython) and then import numpy and scipy.
There seems to be a binary for 14.04, though I don't know the specifics of your platform.
(This does have the downside that it is a very large install, of course, so it may not suit your needs, but it should make it easy, anyway.)
I wish to install python numpy, scipy, and matplotlib packages. I used the following:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
I was able to install and run numpy, but not scipy or matplotlib. I get an error, "No module named scipy", even though installation appeared to proceed normally. I suspect that this has something to do with the version of scipy and bumpy. I am running OS X Version 10.8.4, python 2.7.2 and numpy 1.6.1. I suspect the problem is either the version or the directory which scipy is installed; scipy is in /Users/myname/src/scipy. I couldn't find out where numpy is located (how can this be done? Spotlight search does not indicate file directory, and grep hangs). How can I install scipy and other packages?
It's hard to be 100% sure without a little more information, but I'm 99% sure…
Your problem is that you're installing all this stuff for the MacPorts Python, but then trying to run Apple's Python, which doesn't have any of it installed. (Part of the reason I suspect this is that Apple's Python is version 2.7.2, while MacPorts has been on 2.7.5 for a long time now. The other part of the reason is that this is exactly the same kind of problem people have when they install two different Python X.Y versions without realizing that's what they're doing.)
If you want to use the MacPorts Python, run /opt/local/bin/python instead of just python.
If you know what you're doing, you can change your PATH, or create a symlink, etc., but I suspect you will just confuse yourself further.
I personally think you'd be a lot happier just sticking to Apple's Python. You need to install a Fortran compiler with MacPorts (or Homebrew, or manually, or …), but to install Python packages, just use pip.
(At this point, that last bit of advice probably won't help you, as the first pip on your PATH is probably the MacPorts one, and doesn't match the first python on your PATH. But if you're willing to start over, just port uninstall python, and then look at these blog posts or the dozens of related questions here on SO.)