Reputation: 31
I'm pretty new to programming, so maybe there's something painfully obvious that I've missed, but I've searched a lot around for solutions to this issue without finding any.
I just got a new computer and installed Anaconda and PyCharm for Anaconda. I got it to work fine on my old computer, but when I try to open PyCharm now and create a project, it gets stuck on the creation of the conda environment. Apparently there's a new conda update, so I tried to update to this one in Spyder, which seemed to work fine, but when PyCharm tries creating a new environment, it gets stuck and only displays
"Creating Conda environment"
"$ conda update -n base -c defaults conda"
Does anybody know what's happening? I've tried just waiting it out, but it doesn't seem to be moving forward at all from that point. I've also uninstalled both Anaconda and PyCharm with all their plugins and reinstalling them, but to no avail. Thanks for any help or input!
Sincerely, confused first year student
Upvotes: 1
Views: 12689
Reputation: 1
PyCharm just can't create folder, so it need Admitistrator permision. Open PyCharm as Administrator before creating new project
Upvotes: 0
Reputation: 53
I experienced a similar issue, and I solved it by running PyCharm Professional Edition as an administrator. Yes, when I ran the 'conda env list' command in Anaconda Prompt, my new environment was successfully created.
Upvotes: 3
Reputation: 1
If you use PyCharm to create conda environment, you can choose conda environment not virtualenv.
When you get the error like "can't get the /path/to/", you can open PyCharm with administrator.
If you use "anaconda prompt" to create conda environment, you can use command line like conda create -n py36 python=3.6
. Then you can activate environment using conda activate py36
.
Upvotes: 0
Reputation: 1
In my Experience I just opened PyCharm as administrator and the error was gone!
Upvotes: 0
Reputation: 473
It appears that Sophie
was able to get the conda environment up and running.
However, other newcomers might come across a similar problem with regards to setting up Anaconda for use within PyCharm. Therefore, I provide a guide below that I recently (today) used in order to accomplish this on a fresh install on a new computer. For this I decided to use PyCharm Community Edition 2018.3
and Anaconda3 version 2019.07.
I performed this on Windows 10 Enterprise version 1903
. I have also performed this procedure on Windows 7 Home Premium edition (some time ago).
This will enable you to use PyCharm and Anaconda together, so that you can:
Terminal
window in PyCharm with packages that are installed with Anaconda's version of Python. You can then use both regular python and conda commands to view, update or install packages. For instance, depending on your preference, you could use 'pip list' (python command) or 'conda list' to list installed packages. Python Console
in PyCharm
To accomplish this, please follow these steps:
PyCharm
, and import any settings file you may have from previous PyCharm installation on other computer (optional). Assuming you are starting fresh, create a new project and set the (default) project folder location.Anaconda
. My install location was set to C:\ProgramData\Anaconda3
. Note that 'ProgramData' folder is hidden by default. You should enable viewing of hidden folders in windows explorer, if you need to manually browse for it. Upon installation, I decided to have the options Add Anaconda to my PATH environment variable
and Register Anaconda as my default Python 3.7
set as deselected. Windows Explorer
and paste in C:\ProgramData\Anaconda3
(or your install directory) in the address bar. This should take you to that directory. Navigate to the environments folder named envs
. Select the address bar and copy that address. I got C:\ProgramData\Anaconda3\envs
. You will need this later. Anaconda Navigator (Anaconda3)
. You should see this from the list of newly installed programs. Alternatively, search for it and open it. This will initialize some stuff (unknown to me) that I have found necessary to be able to complete this guide. For the next steps we dont need this program running. You could close it if you want.py37
for simplicity. You only need to do this once for the python projects you will make. It is possible to make more environments if you should need that for some python projects in the future.Anaconda Prompt (Anaconda3)
, preferentially as administrator. Opening as administrator may prevent complications that could occur on some systems. To do so, search for the program and then right-click it, and choose Run as administrator
.conda create -n py37 python=3.7 anaconda
. It should prompt you to install some packages. Enter y
to accept and proceed with the setup. This step may take some time to finish. Once finished, it may show you the needed command to activate the environment. Don't activate it just yet, ie. ignore that message for now.C:\ProgramData\Anaconda3\envs
and environment name py37
, run the following command (alter as needed to match your environment path and name): set PATH=C:\ProgramData\Anaconda\envs\py37\Scripts;C:\ProgramData\Anaconda\envs\py37;%PATH%
conda activate py37
. This will activate your environment.Documents
folder on your machine. To do so, execute this command: cd "C:\Users\YourUsername\Documents"
. echo %PATH% > path_value.txt
. This will export "PATH" values to a text file that can be found in the Documents folder as path_value.txt
. Open this file and copy the content within. This will be needed in the following steps with setting up PyCharm for use with the Anaconda environment. Settings - Tools - Terminal
. Check that Start directory
field contains the path of your project folder, ie. such as C:/Users/YourUsername/Documents/YourProjectFolderName
. Then, select the folder icon for the Environment variables
field. Click the plus symbol, and add a new entry with PATH
and your path value (as found from the path_value.txt
file) in the Name
and Value
fields, respectively. Settings - Project Interpreter - Add Python Interpreter - Conda Environment - Existing environment
. Browse for C:\ProgramData\Anaconda3
(or your install directory). Select the file named python.exe
. I chose to edit the Name
field of this Anaconda python interpreter as Python 3.7 Anaconda
.Settings - Build, Execution, Deployment - Console - Python Console
. Check that the Python interpreter
field contains Project Default (Python 3.7 Anaconda)
or similar entry. The Environment variables
input may be empty. Select the folder button next to it and add a new entry with PATH
and your path value (as found from the path_value.txt
file) in the Name
and Value
fields, respectively. Exactly the same entries as was inputted in step 12. Settings
and search for the Run context configuration
option. Right click it and select a desired shortcut method. Personally I use a keyboard shortcut which is set to Ctrl+Shift+Less
. Once the rest of these steps are followed, this will allow you to run the current python .py file you have open, without having to manually set up configuration options for it (through Add Configuration
option, next to green play button, as seen if you have no configurations set up from before). It will force PyCharm to use the default project interpreter (which now is the desired Anaconda-delivered Python 3.7 installation) for whatever project you have open. To use it, just open a .py python file with some code inside, click anywhere inside of it, and then use your shortcut option.Edit Configuration
or Add Configuration
in the dropdown box next to the green play / run button. Open the Templates
tree, then select Python
. Check that the Python interpreter
option contains Python 3.7 Anaconda
or similar. The Environment variables
field may contain PYTHONUNBUFFERED=1
. Regardless, select the related folder button and add a new entry with PATH
and your path value (as found from the path_value.txt
file) in the Name
and Value
fields, respectively. Exactly the same as we did in steps 12 and 14.Terminal
and Python Console
windows. Or manually close and reopen those windows.
You have now created and activated an (ana)conda environment, and enabled it's use from within PyCharm. You should also now be able to ie. copy your code over to a fresh new file, and then hit ie. Ctrl+Shift+Less
to run the file without having to manually set a configuration file for it.
Hope this helped!
Sources: source1, source2, source3
Upvotes: 9