Unable to import required dependencies, Python with Pandas and Numpy - pandas

I think this question has been asked before on the internet, but the proposed solutions have so far not worked.
I am trying to run a script that imports numpy and pandas. When I run using the Python Console in my IDE (PyCharm), everything works fine. However, when I run the script from the command line, the following error is displayed:
DLL load failed: The specified module could not be found.
and
Unable to import required dependencies
I am using Anaconda Navigator. There my Pandas and Numpy are listed. I tried to uninstall them via the conda shell (conda uninstall numpy, conda uninstall pandas) and then install them again, but without result.
Hope anyone can help.

If you haven't already call this (no quotes)
conda activate "name of environment that has your modules installed"

After trial and error, I de-installed Anaconda and installed pip instead. Then I installed the modules using pip, and it worked like a charm.
(Not the most elegant answer since it does not explain why things went wrong in the first place, but it offered a workable solution at least.)

Related

Conda and Jupyter Notebook Environment Confusion

I am using Jupyter Notebook to help debug some issues I'm having moving between JSON and pandas. The specific application isn't important.
The important part is that I needed to use pandas.json_normalize() which apparently first showed up in pandas version 1.0.3. I was confused when Jupyter said it doesn't exist. I did a version check and got:
In[]: pd.__version
Out[]: 0.25.2
This is not the version of python installed in either my base environment or the conda environment that Jupyter Notebook is running in or that the app is running in. Version checks in both environments in Anaconda Prompt (outside of Jupyter Notebook) confirm this.
What is going on here? Looking around I haven't seen a good answer, but it does appear that other people have had the same issue --- Jupyter defaulting to pandas 0.25.2 for some reason.
It seems that your Notebook is using a different kernel/environment than what you want.
run this in the notebook to see which environment you are using
! which python
or try
import sys
print(sys.executable)
which would show you which environment it's using, if you have env named venv then you will get something like.
/home/your_home_directory/anaconda3/envs/venv/bin/python
If you don't care about all of that and you just want to update the pandas that it's using then copy that path and do this.
! pip install --upgrade pandas
Note that this will also depend on which version of python you are using

haveing problem getting importing tensroflow in jupyter and sypder from anaconda installation

To start out I had a anaconda installation with python 3.5.2. After doing a pip tensorflow installation I got an error something like "nosetest...". I searched stackoverflow and got a suggestion to move to python 3.6.
So I uninstalled the whole of anaconda and python. Then did complete fresh install of anaconda with python 3.6.10. Did a pip install of tensforflow. launched spyder and jupyter and could not import tensorflow. However, when I issue commands from python command prompt things work fine.
So can't seem to get tensorflow to import in spypder or jupyter.
Lastly following another suggest I ran the c:/from/my/anaconda/Scripts/activate base. But that also didn't work in spyder. However in jupyter it seemed to import but then crashed on tf.version
with access violation.
Can you please help, I've tried many things and suggestions, can't seem to get tensorflow to work with python 3.5 or 3.6.
Thanks.
P.S. I remember using python3.5.2 sometime ago with the then tensorflow, I think version 1.1x and everything went smoothly, everything installed and imported worked beautifully.

PyCharm 2018.2.4 and Anaconda 5.3.0

Mine is Anaconda 5.3.0
When I run .py in PyCharm 2018.2.4, why it shows that:
ImportError:
DLL load failed: The specified module could not be found.
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 module could not be found.
It seems that PyCharm 2018.2.4 cannot import numpy??
Does anyone see this problem too? How to fix it? Thank you very much.
You can set the Python interpreter path on PyCharm to the Anaconda one (something like ~/anaconda3/bin/python).
Todo do so, open the Settings dialog >> Project: [ProjName] in the left panel >> Project Interpreter. Now you can add to the list paths to local Python interpreters, or virtual environments in the project folder or in a folder specified in the WORKON_HOME.
More instructions here and here.
I believe I have useful information if not the solution.
I too received the error using python to import numpy from the windows command prompt. Then I realized I could succeed if I used the Anaconda prompt. Curious about the difference, I exited python and examined the PATH environment variable. As I had hoped, it contained Anaconda references that did not exist in the Windows PATH. At the command prompt I typed: path > p.txt and hit enter to create a file since the string was so long. When I opened the file in notepad I copied the Anaconda references to the clipboard (C:\Users\laptop\Anaconda3;C:\Users\laptop\Anaconda3\Library\mingw-w64\bin;C:\Users\laptop\Anaconda3\Library\usr\bin;C:\Users\laptop\Anaconda3\Library\bin;C:\Users\laptop\Anaconda3\Scripts;C:\Users\laptop\Anaconda3\bin;) then used the Advanced Settings under the System Control Panel to Edit the Environment Variable and paste it on the beginning of PATH. The problem seems to have gone away, both in the Windows shell and in Pycharm.
First, try to delete .git file from project folder and re-enable vcs. Then uninstall numpy by:
pip3 uninstall numpy
After that, go to pycharm and open File > settings > Project Intepreter get the python location url ex: usr/bin/python3. Copy that path and open terminal and type:
usr/bin/python3 install numpy. Wait for pycharm indexing and try to run project again
I don't think it's an issue with PyCharm.
I got Anaconda 5.3 today and use PyCharm Pro 2018.2.4. Unfortunately, I got the same error as you do. However, if you go to powershell (if you are on Windows like me), type in python and import numpy you still got the same error.
Not sure why yet but uninstall & reinstall didn't help (and tbh I don't get why this might help in any sense though).
So my current solution is:
Roll back to Anaconda 5.2 with Python 3.6 and everything gets back to working.
I have the same thing, pychrm 2018.2 & Anaconda3 (64-bit) 5.3 on win10
I think the issue is about Anaconda, I have uninstalled the Anaconda 5.3 and installed Anaconda 5.2, then everything is ok

Error when importing NumPy in PyCharm

I have installed NumPy using pip install and it's working fine while using it in the python interpreter on the command line. But whenever I try
import numpy in PyCharm it throws an error module not found.
I already set the right path in the project interpretor and the import numpy command is working fine with other IDEs such as Syder or Jupyter notebook but it doesn't work in PyCharm.
I found a YouTube video that worked for me in importing a package into PyCharm. First, click on the File menu, then click on Settings, then click on Project Interpreter. Look for a + sign to the right and click on that. That allows you to add a package. Then search for your package of choice (I wanted numpy) in the Search bar at the top. Click on the name, and then at the bottom click on Install Package. After a few minutes, it will say, package successfully installed, and sure enough it was. I was able to import numpy the usual way in PyCharm.
Did you install official Python or Anaconda/Miniconda?
I assume PyCharm created either a virtualenv or a conda env, or an isolated Python environment that does not have NumPy installed.
You should either use your global environment instead of virtualenv:
Settings, Project: project-name / Project Interpreter, https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html
Or install NumPy in your virtualenv or conda env.
This is more complicated. If you open Terminal in PyCharm and it says (project-name) in your prompt, try pip install numpy.

anaconda installing numpy/pandas/matplotlib error

first post here, so I'm going to try to be as thorough as possible.
I'm trying to install numpy/matplotlib/pandas for a project. First time trying to use them. I'm following the steps of a tutorial, so I can't vary from that too much (have to use anaconda). I'm using mac OS Sierra 10.12.5
What I've done:
installed python 3, anaconda, and create and initialize a virtual environment using Anaconda. I then type:
conda install numpy pandas matplotlib
The terminal then tells me what new packages will be installed, I proceed. A few are installed successfully, and then I get this error:
CondaError: CondaHTTPError: HTTP None None for url https://repo.continuum.io/pkgs/free/osx-64/mkl-2017.0.3-0.tar.bz2
Elapsed: None
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
I thought this might be a connection issue, as I'm in China, but I've tried multiple times both using and not using a VPN. This problem is really stopping me in my tracks, any ideas?
Have you tried using the pip installer, or installing using the Anaconda navigator? To install using pip, after creating the virtual environment, open a terminal console, and type
source activate [name of virtual environment]
pip install numpy
pip install matplotlib
pip install pandas
Pip is included in the base anaconda installation, so this should work. If your Anaconda installation included the Anaconda Navigator, you can also install these modules through the GUI, by opening the Anaconda Navigator, clicking on the environments tab, selecting the virtual environment, searching for module in the search bar (make sure you select All and not Installed in the dropdown menu next to it), and then selecting the desired modules and clicking the apply button (this is an example).