0

I am working with PyChram 2019.1.3. I created a new conda virtual environment for my new project. While the env works (python 3.7) fine with spyder and JupyterLab, it fails to work with PyCharm.

I tried normal python as well as iPython notebook in the PyCharm. I am receiving the same error. I added the conda location to my System Path variable-PyCharm detects my environment. But, when I tried to make a virtual conda env through PyCharm it throws the following error "CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/noarch/repodata.json.bz2"

import numpy as np

throws the error" (*** = shortened path)

'''C:\Users\***\AppData\Local\Continuum\anaconda3\envs\res37\python.exe 
"E:\***\3_Code/Git/18_Resi/01_Data Exploration.py"
Traceback (most recent call last):
  File "E::\***\01_Data Exploration.py", line 1, in <module>
import numpy as np
 File C:***\AppData\Local\Continuum\anaconda3\envs\res37\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\**\AppData\Local\Continuum\anaconda3\envs\res37\lib\site- 
   packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

Process finished with exit code 1'''

I understand that the PyCharm, even though detecting the coda env, is not able to work with the vir env. How can I solve this?

PPR
  • 395
  • 1
  • 5
  • 17
  • Is the same env running concurrently in both jupyter and in pycharm? – Melvin Jun 11 '19 at 02:16
  • I tried both, running concurrently and running only in PyCharm. I got the same error. – PPR Jun 11 '19 at 02:20
  • Can I verify that your workflow is as follows: 1. On linux, 2. conda create in bash, 3. set pycharm interpreter path to env's python, 4. run code, get error. EDIT: Actually, since you mentioned System Path, I'm suspecting you're on windows. – Melvin Jun 11 '19 at 02:23
  • No, Step 1 and 2 are different. 1. On Windows 10, 2. Conda created in Anaconda Navigator, – PPR Jun 11 '19 at 02:25
  • Ah. I'm not familiar with that, hope someone else can help you with it, sorry. A brief google search yields certain solutions, although I guess you've already tried them. – Melvin Jun 11 '19 at 02:33
  • Thanks, Melvin. I went through many google suggestions without much help. I was unable to replicate my problem in another computer. So something specific to my work computer. – PPR Jun 11 '19 at 02:39
  • You're welcome PPR (although I didn't do anything at all). Not sure if you're still facing the problem, and seeing as no one else responded, I thought I'll state what I would do if I were in your situation. I programmed in python on windows for ~1 year before switching full-time to linux, only switching back when I absolutely need windows (say testing a program/docker that should work on windows). I would uninstall, reboot, then reinstall anaconda, create a new conda env, and 1. activate and make sure it works via cmd, 2. link it to pycharm, make sure it works there, ... – Melvin Jun 11 '19 at 07:17
  • ... 3. run jupyter notebook (not via pycharm, launch from cmd), make sure it works there, then 4. while jupyter is running concurrently, run a program via pycharm using the same python .exe/kernel. Going down the rabbit hole of resolving specific error problems usually isn't productive after say 0.5 hours of trying, and esp for something like a DLL error I might just skip even that. You probably have heard this before too, but linux does make things quite a bit easier imo. It definitely feels harder at the start, but I spend less time debugging such stuff over the long run. Good luck! – Melvin Jun 11 '19 at 07:23
  • "*I added the conda location to my System Path variable*" - as a PyCharm user this doesn't sound correct to me. You should be going through **Preferences** and adding a **Project Interpreter**, making sure to add it as an existing Conda Environment. [The docs have an example for a new project](https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html), but you can change interpreters anytime. – merv Jun 11 '19 at 14:57
  • Possible duplicate of [Using (Ana)conda within PyCharm](https://stackoverflow.com/questions/28390961/using-anaconda-within-pycharm) – merv Jun 11 '19 at 14:59
  • 1
    @Melvin I solved the issue following your instructions. I still don't know what the issue was; Something related to PyCharm not detecting the correct conda env. Additionally, I also manually changed 'Console/Python Console' from settings since PyCharm was not detecting it automatically. Thanks a lot :) – PPR Jun 11 '19 at 18:54
  • @PPR glad it worked! I'm guessing it's related to this: https://youtrack.jetbrains.com/issue/PY-27234 or this: https://stackoverflow.com/questions/54974444/pydev-eclipse-not-loading-mklinit-when-run-from-a-conda-environment – Melvin Jun 12 '19 at 10:38

0 Answers0