cocos.layer package being reported as nonexistent in PyDev - python

I'm currently using Eclipse Juno, PyDev 2.7.5, and Cocos2d 0.5.5 installed through pip.
After reconfiguring the Python interpreter in PyDev, Whenever I type cocos.layer.Layer in a module, it underlines cocos.layer as an error and says Undefined variable from import: layer.
The strange thing is that I can see the cocos.layer package in the PyDev Package Explorer, and yet its reported as nonexistent in the autocomplete and the error detector.
Any idea on what could be going wrong here, or how I can force PyDev to recognize a subpackage?

I haven't checked, but if it finds 'cocos' but not 'cocos.layer', it may be that it's something hard to analyze statically.
In this case, try adding 'cocos.layer' to the forced builtins. See 'http://pydev.org/manual_101_interpreter.html' in the getting started manual for details.

Related

How to resolve "ImportWarning: can't resolve package from __spec__ ..." in Eclipse PyDev for ema_workbench?

I installed the ema workbench with
pip install ema_workbench
and would like to import some module:
from ema_workbench import Model
If I run this in Jupyter notebook or Spyder, it works fine. If I try to run this in Eclipse PyDev 7.1.0.201902031515 , I get following warning:
D:\EclipsePython\App\WinPython\python-3.7.1.amd64\lib\importlib\_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
return f(*args, **kwds)
I thought that my PyDev settings for the Python Interpreter might be wrong. However, the ema_workbench is listed as installed package and the settings seem to be fine ?!
=>How can I fix that annoying warning?
=>Is this a PyDev issue or an issue of the ema_workbench (that is just not shown for Jupyter and Spyder??)
Related questions:
How to suppress ImportWarning in a python unittest script
Unresolved Import Issues with PyDev and Eclipse
edit
I tried to add
-W ignore:ImportWarning
to the "JVM Arguments" of the python run configuration.
I also tried to put following code on the beginning:
import warnings
warnings.filterwarnings('ignore', category=ImportWarning)
Did not work...
Too my knowledge it is an eclipse / pydev issue related to changes in the import system of python. Just google the message and see the many discussions related to it.

Getting PyCharm to import sklearn

Beginner here.
I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn”
The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one.
Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn”
Does anyone know how to solve this problem?
To make sure you have Scikit-learn package installed on your PyCharm IDE, go to File Menu>Settings and search for Interpreter. Select Project Interpreter, and if you dont see Scikit-learn in the list of packages, click the + sign on the right end. It brings us another window with a search bar, where you can type 'Scikit-learn' and install (see screenshots). I hope this helps.
Screenshots:
,
please notice that, in the packages search 'Scikit-learn', instead 'sklearn'
go to terminal- type python -m pip install scikit-learn
then hit enter.
give it some seconds. It will be done.
Sample Image
Double check your python interpreter. Check whether you have select correct interpreter at the first when you create the project.
Or else you can check your interpreter from the project view under External Libraries.
In your case if you didn't select 2.7.10 (/anaconda/bin/python.app) as your interpreter for the project at the beginning still the program give the same error Import error: No module named sklearn.
Same error occurs to me i have fixed by selecting File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn' Press install button. Installation will be done in 10 to 20 seconds.
If issue not resolved please check you PyCharm Interpreter path. Sometimes your machine have Python 2.7 and Python 3.6 both installed and there may be some conflict by choosing one.
I had exactly the same problem. I'm using PyCharm with Anaconda3 & Python 3.7, and I've installed other packages into/via PyCharms just fine (such as numpy, scipy, and others). But although scikit-learn (which contains sklearn, that was initially confusing) seems fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get the "import sklearn" to succeed inside PyCharm.
I finally got a python-expert friend to help me. He verified everything was correctly installed on my system and verified that PyCharm was somehow messing up.
We finally determined that the venv (virtual environment) was not including scikit-learn (sklearn) even though I had imported it properly into the Project Interpreter in PyCharms.
Solution: Delete and recreate the VENV, specifically ticking the box Inherit Global Site Packages
See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
for how to create a new virtual environment and get to that parameter.
SOLVED:
reinstalled Python 3.7.9 (not the latet)
installed numpy 1.17.5 (not the latest)
installed scikit-learn (latest)
sklearn works now!
For Mac OS:
PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window
and you are done.

Django with VS2010 gives me "ImportError: No module named django.core.management" when running

I'm trying to follow this tutorial and I'm getting the following error:
ImportError: No module named django.core.management
I'm completely new to python. I believe Visual studio is using a version of python I already had installed in c:\Python27, could that be causing a problem?
Someone mentioned in a link I found that they had to copy the 'django' folder to the project folder, but I don't know where that would be. I don't even know what the error means really unless there's a missing package (like dll or assembly in .NET?), but I don't know what paths python would use to try to find a package or even what one would look like.
I see there's a PYTHONPATH environment variable that I don't have declared, should I declare that? Should it point to the C:\Python27 directory?
First, do you have checked your "Python Environment" in your project folder? It may seems like...
Here you may find your django with version. If you dont find it then compile setup.py from django folder again with desire python version. And then right click on "Python Environments" from your project and click on "Add/Remove Python Environments" to select python version.
Ok with a lot of fooling around I found this directory:
%LOCALAPPDATA%\Microsoft\Web Platform Installer\installers\PythonDetectInstalls
In a mangled sub-folder there is a powershell script DetectPythonInistalls.ps1 that has these two lines for checking if python is installed already:
$regKey = "hklm:SOFTWARE\Python\PythonCore\$pythonVersion\InstallPath";
$correctRegKey = "hklm:SOFTWARE\Wow6432Node\Python\PythonCore\$pythonVersion\InstallPath";
Uninstalling all my pythons did not remove these keys. After removing these registry keys with regedit, WPI allowed me to install its own version of python 2.7 and all the other goodies to go with the Windows Azure Python SDK and it worked.

Win7/Python3.3: PyLint failed to load its plugins

Good evening! I have installed pylint on python 3.3 and got following problem: at initialization step pylint fails to load plugin modules (from package pylint.checkers). Thanks to debuging I found that problem is in the comand
module = __import__(basename, globals(), globals(), None)
which is executed from __init__.py of the checkers package. basename is correct name of module (file) inside this package but without extension (I have checked this). However ImportError exception is raised. I culdn't step into __import__ function so I don't know what is exact reason of the exception. Is there any way to find out if it is bug of new version of python, incompatibility of pylint and new version of python or my fault (may be in configuring of python or installing of pylint)? My OS is Windows 7.
P.S. Sorry for my weak English. It isn't my native language.
As of 0.26, Python 3.3 is not supported by Pylint. Logilab mainly works with Python 2.x and so help with the most recent 3.x versions is deeply appreciated.
You should approach the team on the python-projects#lists.logilab.org mailing list to discuss this.

Python: Unresolved import error for sqlite3 in PyDev in Eclipse

import sqlite3 generates:
Unused import: sqlite3
Unresolved import: sqlite3
sqlite3 Found at: DatabaseTests
import sqlite3
However, this works perfectly in the terminal when using the python command-line.
I am running on a Mac Mountain Lion, with the default installation of Python. I am using PyDev in Eclipse Indigo.
This is a very old thread but I don't see the solution I found for this problem so I'll post it in hopes that somebody sees this and can then solve the problem:
you need to add 'sqlite3' (without the quotatios) in the 'forced builtins' tab in Window>Preferences>PyDev>Python Interpreter
I fixed this by adding _sqlite3 (note the underscore) to the Forced Built-ins in Window>Preferences>PyDev>Interpreters>Python Interpreter.
I have the same development environment and suffered from the same issue. I have resolved it by
switching to the MacPorts Python,
by only using packages that I install from that project
and by setting the default Python interpreter on Eclipse-Pydev to be the MacPorts executable
This works perfectly for me, with the one hitch that I still sometimes get an Unresolved import warning, but if the package is installed, my script still runs.
Looks like the project references do not have the site-package path added. Try adding the path to sqlite3 (/usr/lib/python2.7/sqlite3/ or the path installed to which you can get from python shell) to project references from Project -> Properties -> Pydev-PYTHOPATH -> External libraries.
I had a similar problem with other imports (simplejson and matplotlib).
I'm working on Ubuntu and the problems with the imports started after upgrading from Ubuntu 11.10 to 12.04 (which also upgraded the python version and the eclipse).
My steps for solving the problem were:
In the terminal, do 'import sys' then 'print sys.executable'. This gives the path to the current interpreter.
In Eclipse - Window->preferences->PyDev->interpreter-python. Remove the old path and add the path retrieved in stage 1.
In the problematic project go to Project->properties->PyDev-PYHTONPATH, the external libraries tab remove old paths and add the correct ones (on Ubuntu one can find it via the synaptic manager, e.g. for simplejson go to the synaptic manager, type simplejson in the search box, mark the right result right-click and choose properties from the menu then choose the 'installed files' tab to see the path for the installed files.
I hope someone will find it useful.

Categories