pydev not recognizing python installation with django - python

I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash.
When I try creating a django project in pydev, I get an error: "Django not found."
What could the problem be?

I had the same problem and this is what I did just after installing eclipse:
Preferences > Interpreter Python
Pressed Auto-config
Selected /Library/Python/x.x/site-packages, which was not selected
(some django folders were in there, persumably the installation)
Clicked apply / OK
Creating a Django project afterwards should be ok.
Good Luck!

go in the menu to window -> preference -> pydev -> Interpreter - Python ; and add the python interpreter there, if you installed the django in a virtual environment you should add the python interpreter of the virtual env ; after adding the interpreter by clicking on new you should now click on Apply , you should see now all the system libs from PYTHONPATH added there between them Django .
hope this will help

Jaffa,
You might have configured your python interpreter in Eclipse prior to installing Django in python.
So what you have to do now is in Eclipse remove the Python interpreter and add it again (now that it has Django installed) and all should work ok.

I was having this same exact problem today, and I just wanted to add some notes to help people out. You can follow the instructions of antonkeren above, but there's one thing to note that was not mentioned. After adding the django directory to the path you must QUIT ECLIPSE OR APTANA STUDIO. After you restart it and try to create a django project it will work.

I stumbled upon this only yesterday myself: Django must not be among the system libraries for this to function...

I had the same problem and had solved it by adding the python home directory to the PATH variable and reconfigure the python interpreter on pydev.

Use auto config in the preferences option and then click apply and then ok.

If everything is done as said above, and still showing "Django not found" while your are trying to create django project, let try to double click 'django-admin' python file that in scripts folder of python. And try to create django project

I think I've got the same problem, Eclipse 3.5.2 on Fedora. In my PyDev Python interpreter settings I've got the site-packages/django folder (site-packages/django/bin too, just in case), but when I try to create a django project I get an error dialogue saying "It seems that the selected interpreter does not have Django available". Looks like I'm going to have to use Eric4, which is a pity because I can't get that working at all on my Windows rig!
Unless I manage to understand the cryptic advice above, "Django must not be among the system libraries for this to function..."

Same problem I have faced today. I took help from these answer.
but in my case it didnt work.
There is small modification in #antonkeren answer.
1) Go to Preferences. Windows > preferences.
2) Search for Pydev
3) Select Python Interpreter
4) Pressed Quick Auto-config
5) now download www.djangoproject.org/downloads django tar and extract on any location.
6) now click on Folder in "Libraries tab" of "System PYTHONPATH" and select your extracted django project folder location.
7) Click on apply and ok.
Creating a Django project afterwards should be ok.
Cheers...!!

Related

PyCharm doesn't detect interpreter

I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10).
To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed.
On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5").
Is there anything I'm doing wrong? What should I do to be able to use PyCharm?
All replies are appreciated. Thanks in advance.
file > new project settings > project Interpreter > click in the drop down and select 'show all' > click the '+' button >
Now, in the Virtualenv Environment tab under the New environment radio button, check the path in the 'Base interpreter:' field. For me, mine was set to an invalid path. Once I had corrected the path to point to python.exe I recreated my new project and PyCharm built the virtualenv.
For me there was a bit more too.... When creating the new project I expanded the drop down and had to verify the directory where the venv directory was being created. Once I had corrected the path here I had to click around a bit to get it to let me create the project.
I'm going to chaulk this up to a bug. I'm using Community edition.
When creating a project in PyCharm, if the interpret is not already selected, in the drop down menu under the projects "Location:", you can click the gear-looking icon to the right of the interpreter option, and click "Add Local"; then select the file location of the python.exe file that you have installed. It will probably be C:\Python35\Python.exe
I faced a Similar issue and was not able to find Python interpreter anywhere on the system.
The problem with it was that python was installed directly with default settings and there was no exe found in
C:\Python35\
and to solve this i tried uninstalling and reinstalling with custom settings and selecting allow for all users as well which did the trick and path was set correctly to
C:\Python35\python.exe.
After whichPycharm was able to detect the interpreter on this path.
PyCharm project interpreter problem Resolved
I installed anaconda python distribution (Anaconda3-5.0.1-Windows-x86_64.exe) from the anaconda website. https://anaconda.org/anaconda/python
What it actually did was it re-installed my Python3.6.3 (pertinent to mention I have windows10, with pyCharm community & python 3.5 already but with the interpreter problem and while installing anaconda I chose the following settings and disabled my antivirus before my anaconda installation):
selecting allow for all users
installation path was set correctly and (stored safely for future)
restart my Computer after installation.(not essential-but I did)
opened Anaconda & Jet brian pycharm
selected new project in PyCharm screen shot of my New project default Python interpreter location = C:\Users\Skboy\PycharmProjects\dani Interpreter = C:\Users\Skboy\AppData\Local\Programs\Python\Python36-32\python.exe
Wow! my pyCharm started working for me,
Resolution : Python6.3 re-installation with proper custom setting
make a python test test1.py program file to print "hello python test world"
Run
now my Python Interpreter(automatically -by default select) Python 3.6.3
edit configuration & check for interpreter
(C:\Users\user1\AppData\Local\Programs\Python\Python36-32\python.exe)
Run
success test Run
worth to mention Anaconda Jupyter is a web based can also be used in case novice user are still having problems
I have had the exact same problem and was unable to find the solution until just now. Hopefully this works for anyone that was struggling with it.
I went to the location of the Python 3.5 (32-Bit) in my C: Drive which it turns out is just a shortcut to the actual Python application, right click on it and select Open file location which should direct you to the application version of python - simply called 'python'. This is the .exe file that PyCharm was looking for to use as the interpreter.
Now go to the configure interpreter menu in Pycharm and type in the file location of the actual python application. To get to mine I had to go to AppData/Local/Programs/Python/Python35-32. Click on the python.exe file and it should work.
This is my first post here so if its formatted incorrectly or doesn't use the conventional terms - sorry. Let me know if the solution worked for anyone else with the problem or if I fluked it.
If you kept the default settings while installing python, Your project interpreter for PyCharm will be:
C:\Users\yourUserName\AppData\Local\Programs\Python\Python36\python.exe
Chose the above location as your project interpreter inside PyCharm.
Depending on which python version you have, it could be either Python36\python.exe or Python35\python.exe.
For me the following solution it worked:
My configuration:
Pycharm Community edition 2019.1.1
Anaconda distribution with python 3.7. Interpreter in standard location.
Problem:
Pycharm was not able to find python interpreter after reinstallation of anaconda distribution.
Solution:
- Make sure you run pycharm as admin (right click and run as admin). This was actually the critical step.
- Create new project (or open an existing one)
- Depending on the choice choose interpter or go to file > settings > project interpreter > choose small gear on rights side > add > on base interpreter choose the 3 dots > paste the location of the interpreter in the anaconda distribution.
Hope it helped someone. For me the blocking point was that for some reason pycharm was not launching with admin rights.
Blockquote

Using Django with Eclipse - making sure Django is installed correctly

all.
Note that I'm a newbie to Django and Python. I keep feeling like I'm missing very small details, and they're probably related to Eclipse's GUI.
Python is installed here:
C:\Python32
...and Django is installed here:
C:\Python32\Lib\site-packages\django
Note that I ran python from a command prompt to check my Version of Django. It worked. I'm running version 1.5.
Problems come when I try to create a new Django project using Eclipse. This is what happens:
I'll specify that I want to create a new Django project
I'll select my interpreter, give my project a name, and select a grammar version (3.0)
"Add Project Directory to PYTHONPATH" is selected
When I click "Next" I get an error message saying that "Django wasn't found".
But when Python is run from a command prompt (and I "import Django"), Python seems to know where Django is. Python doesn't seem know where Django is when I try to create a Django project in Eclipse.
I feel like I'm missing something very, very small - an environment variable or something. Can anyone help? Thanks in advance.
Make sure that you have added the Django install path to the system PYTHONPATH list. For PyDev in Eclipse, the python path can be found under "Window->Preferences->PyDev->Interpreter - Python"
Click on the New Folder button, navigate to the Django install path (it will be found at /usr/lib/python2.7/dist-packages/django if you installed it to the default directory), and click OK

PyDev code analysis missing

I have installed Eclipse 3.7.2 from APT in Ubuntu 12.04, and installed PyDev in Eclipse. First, it warns unused import and unused wild import, but it no longer displays them today. However, it can display errors like missing parenthesis.
I created a new user, and installed PyDev using that user, problem still happens. How can I enable them for warnings? I have not change the code analysis settings.
list all operations could solve it here, for others convenience, and make this question closed
remove the project and recreated it, and this time the project dir is the the PYTHONPATH
remove your python interpretor settings, and set it again in eclipse - window preference - pydev -interpreter Python, refresh the pydev index
Project -> Properties -> PyDev -PYTHONPATH, all is empty. I then "add source folder"
I had the same problem. Went to project properties > pydev - PYTHONPATH, then setting the source folder did it for me !

How to select Python version in PyCharm?

I have PyCharm 1.5.4 and have used the "Open Directory" option to open the contents of a folder in the IDE.
I have Python version 3.2 selected (it shows up under the "External Libraries" node).
How can I select another version of Python (that I already have installed on my machine) so that PyCharm uses that version instead?
File -> Settings
Preferences->Project Interpreter->Python Interpreters
If it's not listed add it.
I think you are saying that you have python2 and python3 installed and have added a reference to each version under Pycharm > Settings > Project Interpreter
What I think you are asking is how do you have some projects run with Python 2 and some projects running with Python 3.
If so, you can look under Run > Edit Configurations
PyCharm 2019.1+
There is a new feature called Interpreter in status bar (scroll down a little bit). This makes switching between python interpreters and seeing which version you’re using easier.
Enable status bar
In case you cannot see the status bar, you can easily activate it by running the Find Action command (Ctrl+Shift+A or ⌘+ ⇧+A on mac). Then type status bar and choose View: Status Bar to see it.
This can also happen in Intellij Ultimate, which has PyCharm integrated. The issue is as diagnosed above, you have the wrong interpreter selected.
The exact method to fix this for any given project is to go to Project Settings...Project and adjust the Project SDK. You can add a New Project SDK if you don't have Python 3 added by navigating to the python3 binary. This will fix the errors listed above. A shortcut to Project Settings is the blue checkerboard-type icon.
You can also add Python 3 as the default interpreter for Python projects. On OSX this is in File..Other Settings...Default Project Structure. There you can set the Project SDK which will now apply on each new project. It can be different on other platforms, but still similar.
Go to:
Files -> Settings -> Project -> *"Your Project Name"* -> Project Interpreter
There you can see which external libraries you have installed for python2 and which for python3.
Select the required python version according to your requirements.
Quick Answer:
File --> Setting
In left side in project section --> Project interpreter
Select desired Project interpreter
Apply + OK
[NOTE]:
Tested on Pycharm 2018 and 2017.

Why doesn't Pydev find Django?

I have Django installed. I also have django-admin.py in my python-2.7 folder. I can import django using my Python shell (DreamPie). But I can't create a new Django project in Pydev. When trying to create a new Pydev Django Project (choosing python2.7 as the interpreter) I receive the following error message:
I went to the link in the message and I have all the pre-requisite to getting started in Django: Django is installed and import django properly works (in the shell).
In Eclipse:
Window --> Preferences --> Interpreter - Python.
Make sure to choose Python2.7 as the interpreter.
Now, click New Folder. Browse to find the path to django (in this case: C:\Django-1.2.5\django).
OK --> Apply --> OK.
That's it. You can create a new Django project.
What helped me (adjust dir and file names according your installation):
I created copy of file Django-1.3-py2.7.egg-info from C:\Python27\Lib\site-packages\ in the same folder with extender *.egg.
Then, in Eclipse dialog
Window -> Preferences -> PyDev -> Interpreter-Python
I used buton New Egg/Zip(s) in order to add this newly created file to System PYTHONPATH list.
This way Eclipse found Django.
I refer to Fabio Zadroznys answer which should work for all of you.
Probably the PYTHONPATH configured in your interpreter is not correct...
I.e.: if you have a structure with
/my/path/django
/my/path/django/init.py
you have to make sure that
/my/path
is added to the PYTHONPATH (and /my/path/django is NOT!!!)
Another thing to note is that right after installing Django, you just have to do a refresh >in your interpreter so that it's recognized (go to the interpreter preferences page, press >'apply' and choose the interpreters to be re-analyzed -- there are already plans to make >this automatic in one of the upcoming releases, but right now you have to do that manually >because the interpreter is analyzed when you configure it and 'set in stone').
LINK:
pydev does not recognize django installation
You can follow any python version. But in your case Django is not installed globally.
Requirement is you need to have Django installed in system.
For checking the django is installed or not
open CMD / terminal (Assuming that Python is already installed)
$ python
$ import django
$ django.VERSION
You can see the output like this. Here I am using Django 3.1
(3, 1, 0, 'final', 0)
Then in the Preferences --> Interpreter - Python --> Click new and add the location where python.exe or Python application resides. Make sure you are naming the Interpreter appropriately for future reference.
Then restart the eclipse and go to New --> Other --> PyDev --> PyDev Django Project
Name your project
Select the Interpreter that you previously created from the drop down.
The above fixes your issue.
not working for me. the attached screensnap shows that django is importable from the pydev shell, and that the path to it is in pydev's SYSTEMPATH.
(since folks have mentioned virtualenv in other questions, i'll mention this is occuring within a virtualbox but i don't think that matters?)
It needs to be in the PATH or in the /usr/bin

Categories