Python: Correct setup of python interpreter in pycharm - python

I already installed some packages, all of them are located into following path:
/usr/local/lib/python3.8
After I start a new project in pyccharm the software for some reason gives me the option to choose some interpeters I already installed into my system. So I have choosen the system interpreter located on
usr/bin/python3.8
My problem now is, I need to reinstall all the packages located into the path above. Is there a way to automatically use the packages already installed and if I install a package with pycharm its automatically located into this folder and for future projects its not needed to reinstall it again?

PyCharm can work with multiple Python interpreters and this happens to be the common problem with using the right one. Here are two ways to make that sure.
First one:
When creating a new project just beneath the location click on the Python interpreter option.
Select the option Previously configured interpreter
Choose the interpreter that has all your installed packages.
Second one:
If you have already created a project, you need to go the file menu and click the "Settings" option.
On the left pane click on the >Project: and then click on the Python Interpreter option.
Select the the right interpreter from the dropdown and all the packages installed with that interpreter will show in the table below.
Apply and click OK. You are done.
Now import any package you have already installed and it should be OK

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.

How to configure interpreter in PyCharm after downgrading python 3.8 to 3.7 on windows?

I want to downgrade my python to 3.7 because the whl that i want to install(https://github.com/intxcc/pyaudio_portaudio/releases) only supports python 3.7.
I tried uninstalling python 3.8 and installing 3.7.But now i can't configure the interpreter in pycharm.
Anyone can help with that?
Thanks
You didn't need to uninstall Python 3.8, because PyCharm supports multiple interpreters. You can have some project using 3.7 and others using 3.8.
To set the interpreter for a specific project, click File and select Settings from the drop down.
In the settings popup, find your project and then Project Interpreter :
Click on the drop-down arrow circled in red, and you will get a list of interpreters available to choose from.
If none of them are correct ones, select Show all, and a new popup with the name Project Interpreters appears on top, listing more interpreters.
If none of those is correct one, click on the + in the upper right corner of the Project Interpreters, and get Add Python Interpreter popup.
It's a good idea to use virtual environments. If you already have a virtual environment inside your project, either delete it or create a new one with a different name (the default name is <your project path>/venv). For example, instead of venv, use venv37.
The drop-down arrow I circled in green will show all the interpreters that PyCharm knows about.
If the new one doesn't show, click on ... (circled in blue), and locate the newly installed interpreter in the file system. Then click OK to close Add Python Interpreter popup, and get back to Project Interpreters.
The new virtual environment will show on that list. Select it and click OK.
Now you should be back in Settings. Click Apply and then OK.
From now on, this PyCharm project will be using the new interpreter.

PyCharm 5.0.1 doesn't resolve builtin modules / methods

My PyCharm 5.0.1 installation does not resolve references to any builtin modules or methods:
As you can see, I have installed python over cygwin.
I already tried:
reinstalling / updating the python installation (from 2.7.9 to 2.7.10)
reinstalling pycharm
adding a interpreter path to the python-skeletons in the pycharm installation directory (this was immediately removed by the ide when saving the settings, implying, that it already is embedded)
removing the interpreter (this removes the warnings, but also the code completion, and import asdflkjasd is valid as well)
adding various paths like /lib/python2.7/site-packages/ to the interpreter packages option
None of these improved the situation.
How can I fix this without installation outside of cygwin alltogether?
This is an update with a much better solution than my previous answer (which I completely missed that OP was asking for a solution that didn't require exactly what I suggested).
Like Carl commented above, updating python-skeletons is actually the way to go, however, if you're using Cygwin, the interpreter paths are a little wonky, and PyCharm won't always automatically add the right paths. For me, PyCharm handled it just fine in version 4.5.4, but not 5.0.4.
You'll find the python builtins in your Pycharm config directory, probably at:
C:\Users\[USERNAME]\.PyCharm50\system\python_stubs\-[RANDOM_STRING_OF_NUMBERS]
Just manually add this path (or paths) to your interpreter and it should resolve your problem. You can do the same for your site-packages folder if that's currently polluting your project structure space.
To get to the right menu:
Click File -> Settings
Navigate to Project -> Project Interpreter
Click the gear on the top right and click "More"
Select your interpreter and click the "Show paths" button on the right
Instead of clicking refresh, as many other posts suggest, click the "Add" button on the right and add your paths
There's a handy screenshot uploaded by r---------k on the updating python-skeletons post that if that helps you.
Try installing the Python package for Windows from
http://www.python.org/download/windows and point PyCharm to that
interpreter instead.
Settings -> Project -> Project Interpreter -> Gear -> Add Local
You may also need to install PyCharm's Python packaging tools (you
should see a link on the bottom of the Project Interpreter page if it
isn't installed already).
While this may not be a perfect solution depending on your workflow
because PyCharm will no longer be using Cygwin's python interpreter,
but this at least got rid of those pesky squiggly red underlines for
me.
I use Windows 10 x64, Python 3.5.1 and PyCharm Community Edition 2016.1.4
I have the same problem and sovled it by runnig PyCharm in admin mode (it is required only once).

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

Trying to get PyCharm to work, keep getting "No Python interpreter selected"

I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Your problem probably is that you haven't installed python. Meaning that, if you are using Windows, you have not downloaded the installer for Windows, that you can find on the official Python website.
In case you have, chances are that PyCharm cannot find your Python installation because its not in the default location, which is usually C:\Python27 or C:\Python33 (for me at least).
So, if you have installed Python and it still gives this error, then there can be two things that have happened:
You use a virtualenv and that virtualenv has been deleted or the filepath changed. In this case, you will have to find proceed to the next part of this answer.
Your python installation is not in its default place, in which case you will need to find its location, and locate the python.exe file.
Once you have located the necessary binaries, you will need to tell PyCharm were to look:
Open your settings dialogue CTRL + ALT + S
Then you will need to type in interpreter in the search box:
As you can see above, you will need to go to Project Interpreter and then go to Python Interpreter. The location has been selected for you in the above image.
To the side you will see a couple of options as icons, click the big + icon, then click on local, because your interpreter is on this computer.
This will open up a dialogue box. Make sure to select the python.exe file of that directory, do not give pycharm the whole directory. It just wants the interpreter.
Go to File->Settings->Project Settings->Project Interpreter->Python Interpreters
There will be a "+" sign on the right side. Navigate to your python binary, PyCharm will figure out the rest.
This situation occurred to me when I uninstalled a method and tried to reinstall it. My very same interpreter, which worked before, suddenly stopped working. And this error occurred.
I tried restarting my PC, reinstalling Pycharm, invalidating caches, nothing worked.
Then I went here to reinstall the interpreter:
https://www.python.org/downloads/
When you install it, there's an option to fix the python.exe interpreter. Click that. My IDE went back to normal working conditions.
During the install of python make sure you have "Install for all users" selected.
Uninstall python and do a custom install and check "Install for all users".
Even I got the same issue and my mistake was that I didn't download python MSI file. You will get it here: https://www.python.org/downloads/
Once you download the msi, run the setup and that will solve the problem. After that you can go to File->Settings->Project Settings->Project Interpreter->Python Interpreters
and select the python.exe file. (This file will be available at c:\Python34)
Select the python.exe file. That's it.
for mac I can tell you that first you have to check your path
by executing this command
which python or which python3
then you have to configure it in your pycharm.
pycharm-->preferences-->gear button-->add..
click on system interpreter--> then on ...
then you search where your python version is installed
once it is done then you have to configure for your project
click on edit configuration
then choose the python interpreter
If you are using Ubuntu, Python has already been downloaded on your PC.
so, go to -> ctrl + alt + s -> search interpreter -> go to project interpreter than select Python 3.6 in the dropdown menu.
Edit: If there is no Python interpreter in drop-down menu, you should click the gear icon that on the right of the drop-down menu --> add --> select an interpreter.
(on PyCharm 2018.2.4 Community Edition)
I got the same issue when i newly installed pycharm in my windows 10 machine.
download python setup
install this solved my problem.
for more help visit
goodluck
During the install of python make sure you have "Install for all users" selected. Uninstall python and do a custom install and check "Install for all users"
In my case, there are several interpreters, but I have to manually add them.
To the right of where you see "No Interpreters", there is a gear icon. Click the gear icon -> Click "Add...", then you can add the ones you need.
In Linux, it was solved by opening PyCharm from the terminal and leaving it open. After that, I was able to choose the correct interpreter in preferences. In my case, linked to a virtual environment (venv).
You don't have Python Interpreter installed on your machine whereas Pycharm is looking for a Python interpreter, just go to https://www.python.org/downloads/
and download python and then create a new project, you'll be all set!
I had the same problem and stumbled onto this solution.
I ran PyCharm (as administrator, though not sure if necessary).
After PyCharm has completely loaded (green tick mark top right), see bottom right. Click on it.
An interface will open. In my case the path was already there. I just clicked OK and all was fine.
closed PyCharm and ran it again normally. Still all fine.
I has to close PyCharm, delete the .idea folder then open PyCharm again.

Categories

Resources