python interpreter not found for Django project after re-installing python - 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.

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.

PyCharm to use virtualenv and dependencies created by PyCharm

I have created a virtualenv using command prompt and have installed all my dependencies. How can I make PyCharm use the virtual env & dependencies created via command prompt?
You should link the virtualenv in PyCharm.
In order to do this, go to:
File -> Settings -> Project -> Project Interpreter
Here, in the top right corner of the window, click on the gear icon and choose Add.
Then, choose Existing environment option and navigate in your computer until you find the python.exe for your virtualenv.
Than confirm modifications clicking Ok. This should be enough.
If you want to use it in a PyCharm configuration, please do not forget to choose it in the Python Interpreter option.

How do I install packages in PyCharm for all projects?

I use PyCharm and all the initial settings are okay.Simple package installation is working. Then why do I need to reinstall a package for each project? Is there any way to install the packages for all projects from now on?
This is depending on your project settings, the project interpreter to be specific.
The project interpreter can be set to one of the following:
an interpreter installed globally on your system
an interpreter in a shared virtual environment
an interpreter in a virtual environment associated with a project
Now the approach I'd recommend would be to create a shared virtual environment where you install your packages to, and use this environment for all your project.
That way, you have the desired result of needing to install your packages only once, but still have an environment isolated from your system environment.
To create such an environment, follow these steps:
Settings -> Project -> Project Interpreter
Click the cogwheel / gear icon right-side the interpreter dropdown
Select "Add Local..." -> Virtualenv Environment
Select a path as a root directory for the new environment
Select base interpreter you want to use
Tick the checkbox "Make available to all projects"
Click the "OK" button to save the new environment
You can download Package from the Pycharm IDE
1. Open Pycharm and Go to File
2. Click on Settings
3. On left Side, You will find Projects Option. Click & Expend it
4. Click on Interpreter
5. A list of installed package will be shown
6. On Right Side, You will see a + button. Click This to install new package
7. A window will appear with Search bar, then search your package name and hit install button.
All steps are taken from this One minute Video.

How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?

There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.
Am I missing something obvious?
With the Python plugin installed:
Navigate to File > Project Structure.
Under the Project menu for Project SDK, select "New" and
Select "Python SDK", then select "Local".
Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.
I was getting the error (IntelliJ on Ubuntu 18.04) while python SDK was configured.
To fix that, I had to do this:
File -> Project Structure -> Modules
Click on the Dependencies tab, and click on + and select the python SDK
Click on Apply
After that, the warning went away and autocompletion also started working properly
So here is a simple project, where I have used Selenium and added that using external path
Now you need to open Project Structure and go to SDK Section
Now Select your project's virtual environment. In the Classpath tab add the PYTHONPATH by clicking + button
and now the modules will be recognized
If you have multiple modules in your project, with different languages, you can set the interpreter in the following way:
File -> Project Structure...
Select Modules in the list on the left
Select the Python module in the list of modules
On the right-hand side, either choose an existing Python SDK from the dropdown list, or click on the New... button to create either a virtualenv, or create a new Python SDK from a Python installation on your system.
Follow these steps:
Open Setting (Ctrl + Alt + s)
Click on plugins
Find Browse Repositories and click
Search for "python"
Select Python SDK or pycharm
Restart the IDE
Go to project structure
Select the python SDK in projects or create a new project with python SDK.

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

Categories

Resources