PyCharm does not recognize the interpreter it just created - python

Problem Statement
My PyCharm project does not recognize any Virtualenv project interpreter, including ones it successfully creates.
Steps Taken to Produce Error
I opened PyCharm to the Welcome to PyCharm window.
I clicked Get from Version Control. I cloned a private repo from my GitHub into my local system. I confirmed that all files from the repo were present.
I opened the Add Python Interpreter window via File -> Settings -> Project: myProject -> Project Interpreter -> (gear button) -> "Add...".
I selected the Virtualenv Environment option and the New environment radio button. I confirmed that the target Location (...\myProject\venv) did not yet exist. I selected Python 3.7 as my base interpreter, an installation which I have used without issue in other projects. I left both Inherit global site-packages and Make available to all projects unchecked.
PyCharm successfully created the Virtualenv. I confirmed this in both PyCharm's Project tab and Windows Explorer. Double-clicking ...\myProject\venv\Scripts\python.exe launched a Python 3.7 shell as expected.
However, PyCharm's infobar at the bottom of the main window said <No interpreter>. The Project Interpreter settings menu also said <No interpreter>, and upon expanding the interpreter list dropdown, the interpreter which PyCharm had just successfully created for myProject was not listed.
Note
After taking the above steps, the newly-created Virtualenv is listed as an option under the Existing Interpreter radio button. However, selecting this option does nothing; the Project Interpreter window still says <No interpreter>.
Failed Remedies
Closing and Reopening PyCharm.
Choosing the Existing Interpreter radio button and targeting myProject\venv\Scripts\python.exe.
Choosing the Existing Interpreter radio button and targeting the python.exe in a different project's Virtualenv.
Restarting my computer then Existing Interpreter -> myProject\venv\Scripts\python.exe.
Creating a second Virtualenv (myProject\venv-2).
Deleting all existing Virtualenvs, then creating a new one in myProject\venv.
Leads
Creating a new, separate project (myProject_2) using the exact same steps as above does NOT replicate the error; a new Virtualenv is successfully created and recognized. This error is unique to myProject.
Regardless, I'm going to leave this question up. I want to understand what's going wrong here.
[Project Directory Structure]
myProject
assets
css
images
js
MyProject
courses
migrations
templates
courses
templatetags
templates
users
migrations
templates
users
templatetags
venv
[Info]
Microsoft Windows 10 Pro
PyCharm 2019.3.3
Python 3.7.7

The solution suggested in this answer to a related question—where the error message "Please specify a different SDK name" is being raised—about PyCharm interpreters may be what you are looking for.
I also had an issue with interpreters not loading, and it turned out to be an underlying conflict, which PyCharm was not giving me any helpful error messages about. The issue wasn't resolved until I deleted the jdk.table.xml file, which for me (on Mac OS) was located here: ~/Library/Application Support/JetBrains/PyCharm2022.2/options.

Related

Pycharm does not show recommendations [duplicate]

PyCharm's autocomplete isn't working for installed libraries. I have the following code:
from boto.emr.connection import EmrConnection
conn = EmrConnection(aws_keys.access_key_id, aws_keys.secret_key)
I want the editor to tell me what methods I have available to me when I press Ctrl+Space.
The boto library is installed in my environment, but it doesn't seem to be detected by PyCharm. How can I set this up correctly?
You've installed the 3rd-party library into a virtualenv, but PyCharm doesn't know about that by default. If nothing is specified, it will choose the system Python install as the interpreter. You need to go into the project settings and configure the interpreter to point at the virtualenv. PyCharm will then index the interpreter and allow you to autocomplete.
The virtualenv may be auto-detected in the dropdown menu on the left. If it is not, click the gear to the right, click "Add local", and select /path/to/virtualenv/bin/python (or \Path\to\virtualenv\Scripts\python.exe on Windows).
The above answer didn't work for me, because I wasn't able to find any project related setting in my setting,and the python Interpreter was empty.
The solution was to delete .idea file, from project root, close Pychram then go to project directory and open it with Pycharm:
$pycharm-professional or $pycharm-professional .
when it lunch a pop up window on the bottom right will appear and as you the following
select configure python interpreter then a new window must appear:
chose to use Pipenv as your interpreter or any other solution that is for your case.
Now the Project setting should appear again in Pycharm setting, and the recommendation must be already working.

python interpreter not found for Django project after re-installing python

I have made an application using Django in pycharmIDE.after completing my project I deleted python from my machine and re-installed now when I run my application it shows
No Python at 'C:\Users\Raisan\AppData\Local\Programs\Python\Python37-32\python.exe'
how can I set python interpreter in Pycharm
In order to set Python interpreter in a PyCharm project, you should click on:
File -> Settings -> Project -> Project Interpreter
Then, on the top of the window, you should have a dropdown selection with Project Interpreter label. Here you can choose the project interpreter for your project.
If the interpreter is not present, click on the settings icon (gear wheel) on the right anc choose "Add".
Then choose "Existing enviroment" and navigate througth your directories until you will find your Interpreter.
Remember that you have to select the python.exe file.
Please set environment variable and try it otherwise uninstall python and and reinstall it but that time select custom python install and choose appropriate options like IDEdevelopment environment pip etc.

How to enable PyCharm code inspection for packages

I recently created a Python package which I use in most of my projects so I moved it to my user-site directory (python -m site --user-site). Everything works perfectly now except for the fact that PyCharm has disabled code inspection for it.
Is there any way for me to enable code inspection without moving the project back to a different directory?
It turns out it was because I didn't have an interpreter set for my project (and not that it was placed in a site-packages directory). I assumed that it did due to the fact that PyCharm didn't have it's usual "no interpreter configured for this project" alert. Finally figured it out when I went poking in the settings.

Using IntellijIdea within an existing virtualenv

I want to use Intellij Idea within my existing python django project which was built within a virtual environment in ubuntu. How do I configure Intellij Idea to use the libraries of the virtual environment?
For PyCharm 2018
As per documentation from Pycharm:
In the Project Interpreter page, click and select Add.
In the left-hand pane of the Add Python Interpreter dialog box, select Virtualenv Environment. The following actions depend on whether
the virtual environment existed before.
If Existing environment is selected:
Specify the required interpreter: use the drop-down list, or click Select an interpreter and find one in your file system.
Select the check-box Make available to all projects, if needed.
Click OK to complete the task.
For Pycharm 2016 and later
To add an existing virtual environment to the list of available interpreters
In the Project Interpreter page, click .
In the drop-down list, choose Add local.
In the Select Python Interpreter dialog box that opens, choose the desired Python executable, located inside the virtual environment folder, and click OK.
Go to this link for more information.
For Older versions:
Well I solved the above problem. I have added virtualenv folder's python to project sdk. The virtualenv directory's python( for example venv/bin/python2.7) needs to be added to Intellij Idea project path. Example: need to go to file>project structure (intellij Idea)
press new in Project SDK, and add new path to virtualenv's python directory like this:
Go to Modules>Dependencies and set your module sdk to Python SDK which is marked on this picture:
Click on Django (option marked in next the image) and set Django project root, Settings,Manage Script like this:
Now press ok and final look of the Project settings:
Now need to run the project.
The above answer is based on older version of IntelliJ. For new, look here: https://www.jetbrains.com/help/pycharm/2016.1/adding-existing-virtual-environment.html

Virtualenv with Eclipse (Galileo) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Does anybody have directions for getting Eclipse (Galileo), PyDev, and Virtualenv working together? I'm specifically trying to run Pinax but any instructions are fine.
I thought I had it (and even blogged everything but the final step - interactive debugging) and still there is no solution. I'm specifically on OS X but any answer should be sufficient. This is the best resource I've found so far:
http://blog.vlku.com/index.php/2009/06/10/djangoeclipse-with-code-complete-screencast/
I'd disagree with having to go through all the hassle of creating and maintaining a separate workspace for every virtual environment.
All you need to do is set up a separate interpreter per virtualenv and make sure the project is using it.
Along with your standard interpreters such as Python 2.5, Python 2.6, Python 3.1 you'll also add some more along the lines My Django Website, My Cool Project, My Other Cool Project--where each interpreter will have all the PYTHONPATH entries as it's virtualenv would provide.
What problems are you having?
The key is having separate workspaces for each project. Then select the python interpreter for that workspace to the one created for the virtualenv. Then you should be set.
My instructions for creating a Django Virtual Environment which works with Eclipse are as follows;
Note: The instructions are for OSX Mountain Lion, but should work with other operating systems. I have collated this information from various sources and would appreciate any suggestions or comments. I will assume you have python, virtualenv and eclipse set up on your system.
Open a terminal, move to the location you would like to have your eclipse workspace and;
mkdir projectenv
cd project env
virtualenv venv --distribute
source venv/bin/activate
Now, lets install the dependencies;
pip install Django psycopg2 dj-database-url (Your needs may vary from mine)
Now we will start the Django project and commit to git;
django-admin.py startproject myproject
pip freeze > requirements.txt
git init; git add; git commit -m myproject (Please have a .gitignore file with venv and *pyc in it before doing this step)
Our django project is set up and ready to go, so now open eclipse and at the workspace selector, click browse and select the projectenv folder (i.e. the folder which contains the venv folder, the myproject folder and the requirements.txt folder) and click open.
Go to File, Import, General, Existing Folder as New Project and select the myproject folder, click finish. Your project will now appear in the package explorer - you should now switch to the PyDev perspective if not already on it.
Right click on the main myproject folder in the package explorer, go down to PyDev and select 'Set as PyDev project'. Eclipse will now prompt you to set up the interpreter and will take you to the preferences window. Click New, and select the interpreter in /venv/bin/ select python, not python2.7 and click ok.
You will get a list of libs, leave them as they are and click finish, you will get a warning, but click proceed anyway.
Now, click on New Folder in the bottom half of the prefs window and select /venv/lib/, click ok, then click apply, then click ok.
Finally, right click on manage.py and Run As, Run Configurations. In the Arguments tab, type;
runserver --noreload
then click Apply and then Close.
That should be that, when you want to add an app, do so on the command line as you normally would using manage.py startapp myapp (if you install the Aptana Studio plugin, you can get a terminal window inside eclipse), right click the main project folder in eclipse and hit refresh, everything will be there. When you want to debug, set your breakpoints, hit Debug As python manage.py (the config you set up earlier) and when you hit a code breakpoint, Eclipse fires you into the debug perspective.
I find this gives me the perfect mix, it means I can write a lot of stuff on the command line as normal, but because it's set up in Eclipse, when things aren't going my way, I can fire up eclipse and do some real debugging!
I hope this helps.
Not sure about Galileo since I have upgraded to Helios.
It's easy to setup Project->PyDev - Interpreter/Grammar -> Interpreter based on different projects. When configure the interpreter to point to virtualenv's python interpreter, Pydev doesn't automatically inherit the system python's path, therefore it's the user's duty to select appropriate PYTHONPATH. But you can always go back to edit that in Preferences->Pydev->Interperter - Python -> Libraries tab.
Based on the information here (and others found when I was trying to solve the same problem you had), I put together a post with step-by-step instructions here.
The short answer, as the Doctor says, is to make each virtualenv correspond to a workspace - so when you create a new one of the former, you create a new one of the latter exclusively to use with it.

Categories

Resources