9
votes

I'm having issues adding a project interpreter to PyCharm from a new Anaconda environment. I have Anaconda2 installed with one Python 2.7 environment (C:\Anaconda2\python.exe) that I've been using on Pycharm without issue for several months.

I am attempting to add a second Python 3.6 interpreter (from C:\Anaconda2\envs\py36\python.exe) to my PyCharm. After adding the Local Interpreter to Pycharm, I run into a MS Visual C++ Runtime Error R6034 "An application has made an attempt to load the C runtime library incorrectly".

From cursory googling, it seems that there could be a runtime DLL conflict (potentially msvcr90.dll) between Python 2 & 3. All fixes I see involve editing the executable path of the application, but I don't think this is feasible for my Pycharm use case. How do I get rid of this error, or just generally be able to use both Python 2 & 3 interpreters through my PyCharm?

3
I'm having the same issue - Robert

3 Answers

2
votes

I think that's the problem with Anaconda and different msvc dll in the computer.

You can test the conda command in the command line, to see if R6034 happens. If it happens, try the following solution:

I had a similar problem with Anaconda3 and Python27. I solved this problem via executing the following command in cmd, outside of any conda environment:

conda install msvc_runtime

After installing the packages, open a new command and test if the R6034 error still appears.

1
votes

I had a similar issue and was able to resolve it by selecting:

File --> Invalid Caches / Restart...

from PyCharm's main menu.

You may also want to double check that any Conda Environments that you have defined as Python Interpreters in PyCharm are properly configured per the docs

1
votes

This issue was absolutely maddening. Million R6034 error windows would just keep popping up one after another if I just wanted to get help on a function. I researched it for months, on/off, opened tickets with JetBrains to no avail.

If you need to have multiple versions of Anaconda, and if you have Anaconda paths in your PATH, before launching PyCharm, delete all Anaconda paths from PATH, and then start PyCharm. You need to create a separate wrapper launcher script for PyCharm to fix PATH before PyCharm is started. Note that alternative of starting PyCharm and then fixing interpreter and python console PATHS inside PyCharm do not really work. Because PyCharm may be using a system path to access python to read documentation etc. So the only clean fix is to fix the system PATH before PyCharm starts.

Once you understand what needs to be done, then you can use your own steps/tools. This worked for me:

  1. Create a script that modifies PATH. I used Python for that, sed or any other tools are fine too. The script simply examines each path element and removes it if it refers to Anaconda, and then puts it back together:

    path_cleanup.py:

    path_old = os.environ['PATH']
    path_python_removed = [loc for loc in path_old.split(pathsep) if not ('python' in loc or 'Ana' in loc)]
    print(pathsep.join(path_python_removed))
    
  2. Create Powershell script to fix PATH and start PyCharm from that clean environment. To find PyCharm path, the simplest is to start it up the usual way, and head to Task Manager, right mouse click on pycharm64.exe process and select "open file location" to get the full path. pycharm_clean.ps1

    $Env:Path=python path_cleanup.py   # call the script to fix the PATH
    start-process $PYCHARM_PATH\pcharm64.exe -WindowStyle Hidden  # enter your full path to pycharm and put it into background.
    
  3. You can create a shortcut to launch pycharm_clean.ps1 + you can add it to your windows start up folder to be launched upon login: %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\

If you use BASH inside Cygwin, then steps for path clean up require a bit more tuning, but nothing you cannot do. If you need help, put a comment and I can add that script as well.