Eclipse not able to find libraries after reinstall - python

I had to reinstall my OS and now I can't load my old projects on Eclipse IDE. At first it didn't find the GAE source folder, as it was not on the same location where it was when I created the project, so I just changued the variable $GOOGLE_APP_ENGINE to where it really was.
But now it seems that on the new version of the GAE source the library folders have different names, and Eclipse won't find them.
How can I make Eclipse modify the info on my old projects so it updates the library folders names?
Thank you very much.

If you are using python, you need to set the correct paths on Project -> Properties -> External Libraries or edit the .pydevproject file. I did it a few days ago, just replace the ones that can't be found with the ones below.
<pydev_project>
....
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>GOOGLE_APP_ENGINE</key>
<value>/usr/Local/google_appengine</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>${GOOGLE_APP_ENGINE}/lib/antlr3</path>
<path>${GOOGLE_APP_ENGINE}/lib/enum</path>
<path>${GOOGLE_APP_ENGINE}/lib/fancy_urllib</path>
<path>${GOOGLE_APP_ENGINE}/lib/google-api-python-client</path>
<path>${GOOGLE_APP_ENGINE}/lib/graphy</path>
<path>${GOOGLE_APP_ENGINE}/lib/grizzled</path>
<path>${GOOGLE_APP_ENGINE}/lib/httplib2</path>
<path>${GOOGLE_APP_ENGINE}/lib/ipaddr</path>
<path>${GOOGLE_APP_ENGINE}/lib/oauth2</path>
<path>${GOOGLE_APP_ENGINE}/lib/prettytable</path>
<path>${GOOGLE_APP_ENGINE}/lib/protorpc</path>
<path>${GOOGLE_APP_ENGINE}/lib/python-gflags/tests</path>
<path>${GOOGLE_APP_ENGINE}/lib/simplejson</path>
<path>${GOOGLE_APP_ENGINE}/lib/sqlcmd</path>
<path>${GOOGLE_APP_ENGINE}/lib/yaml/lib</path>
<path>${GOOGLE_APP_ENGINE}/lib/django-1.4</path>
<path>${GOOGLE_APP_ENGINE}/lib/webapp2-2.5.2</path>
<path>${GOOGLE_APP_ENGINE}/lib/markupsafe-0.15</path>
<path>${GOOGLE_APP_ENGINE}/lib/jinja2-2.6</path>
<path>${GOOGLE_APP_ENGINE}/lib/webob-1.1.1</path>
<path>${GOOGLE_APP_ENGINE}</path>
</pydev_pathproperty>
</pydev_project>

Related

Is it possible to get to the code from egg-link?

I made some modifications to the code for a deep learning model implemented in MxNet.
On my local computer, I installed MxNet by conda/pip, so I could just go to the installation folder, where I found the files where the model architecture is specified and made my changes. The structure is like:
.../environment_folder/lib/python3.8/site-packages/
- gluoncv/model_zoo/action_recognition/i3d_resnet.py
- mxnet/gluon/block.py
and I made my changes to these files.
Now, I need to do the same on another machine, where MxNet has been compiled from source. I looked into the analogous installation folder, and I found the following structure:
.../environment_folder/lib/python3.8/site-packages/
- gluoncv/model_zoo/action_recognition/i3d_resnet.py
- mxnet.egg-link
i.e., I found the gluoncv folder, but instead of the mxnet one there is a egg-link. I honestly didn't know about egg files, I've been searching around and found it was an old way of packaging python files before wheels and pip. Is there any way I can open the link and get to the folder it is presumably pointing to?
If you can open a python shell prompt (with the environment loaded) on the machine in question, try:
import mxnet
mxnet.__file__

'reportMissingModuleSource' and 'reportMissingImports' errors for imported modules pandas and alpha_vantage

I'm very new to python and trying one of my first projects. I have installed modules 'pandas' and 'alpha_vantage' and imported them at the top of my code but they show the errors 'reportMissingModuleSource' for pandas and 'reportMissingImports' for alpha_vantage. I installed them in Command prompt and it was successful but it seems python doesn't recognise them or cant find them.
Potentially useful info:
When I first installed python I had to go into my Path settings and create a new Path to python.
I use VSCode
I had issues installing pip I cant remember why because I've been at this for hours.
Python version is 3.10.5 64bit
Pip version is 22.1.2
I am on Windows
I don't know what python files need to go where so they are slightly scattered around my directory.
Do I need to create a Path in my settings to each module, I already have one going to my scripts folder. I am very stuck so any help is appreciated.
Thank you for anyone that helps!

What other ways can python look for modules?

We have a software called ArcGIS that comes with a python environment, which has a library called arcpy
When you execute the python.exe from that environment, it imports arcpy with no issue.
But I needed to create another python enviroment that contains the same library as this one, but I just couldn't find anything named arcpy in the enviroment's folders
I even copied the whole Lib folder from the original enviroment to the one I'm trying to create, but it still won't import arcpy
I know this is kinda of a shot in the dark, as it is a proprietary library and I can't be sharing much info, but does anyone knows what could it be?
It seems they use Anaconda too
The python (arcpy) install with ArcGIS typicall installs to:
C:\Python27\ArcGIS10.5
Arcpy does not like to be moved, and the library is linked directly with your ArcGIS installation
C:\Program Files (x86)\ArcGIS\Desktop10.5
If you are using ArcGIS Pro rather than Desktop, it installs into Conda environment:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\
This Q&A on GIS Stack Exchange may be of some interest to you - How to set up Python/ArcPy with ArcGIS Pro 1.3
Go inside the environment with arcpy, look for the environment var PYTHON_PATH. and just add that path to the PYTHON_PATH in your new environment.

Use spatialite extension for SQLite on Windows

I know that this has been asked in some similar ways before. However, all questions I found on this dealt with some very specific system setups which were not applicable for me (because so is mine).
System:
Windows 7 64bit
Python 3.4 64bit
sqlite3 2.6.0 (shipped with Python I guess)
Spatialite Windows binaries 2.3.1
(anything else of importance?)
How can I activate the spatialite extension for the ´sqlite3´ module?
What I tried (the way that other people in similar questions say it works):
Downloading from https://www.gaia-gis.it/spatialite-2.3.1/binaries.html :
libspatialite-win-x86-2.3.1.zip
proj-win-x86-4.6.1.zip
geos-win-x86-3.1.1.zip
libiconv-win-x86-1.9.2.zip
unzipping all of them into the same folder on C:\
(also tried only putting the DLLs into that folder)
putting that folder into my system PATH variable
Then, running
import sqlite3
conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
conn.execute('SELECT load_extension("libspatialite-2.dll")')
gives
conn.execute("SELECT load_extension('libspatialite-2.dll')")
sqlite3.OperationalError: The specified module could not be found.
What more can I try to make this work?
you probably don't have the folder in which libspatialite-2.dll is placed in your PATH.
Perhaps you can add the folder from within your Python script (I don't know any Python).
Or else you could add it from the Windows properties interface.
BTW you are using a very old version of spatialite: have a look here for newer versions:
https://www.gaia-gis.it/fossil/libspatialite/index
I have recently faced this problem with mod_spatialite.dll with Spatialite 5.0.1, Python 3.8 (with Anaconda) and Windows 10. I fixed the problem with the following steps:
Installed OSGeo4W;
Copied all the files and folders in OSGeo4W64\bin to anaconda3\Library\bin (without replacing the existing files, as this may break other things in the Python installation). I backed up this folder beforehand so I could undo everything, just in case things go wrong;
Copied mod_spatialite.dll (which I had already downloaded) into anaconda3\Library\bin.
The reason why I think I had this problem is because of missing recursive dll dependencies; since just getting the direct dependencies (through dumpbin /dependents mod_spatialite.dll) and copying them to the anaconda3\Library\bin folder did not solve the problem, so I came to the conclusion that I was missing a dependency of some dependency. Given that all dependencies are already neatly placed in OSGeo4W64\bin, copying everything from there solved it for me.

Easy Install for Python and Eclipse Library Paths

Recently I found about this tool easy_install that help me to easy install additional python modules. The problem is that for each module it creates additional *.egg folder (sometime there is only an egg file?) (no source?) and I don't know how to setup eclipse paths.
By default I have included C:\Python26\Lib\site-packages and this is enough when I install python modules from source... but not when I'm using easy_intall
For example django instaled with easy_install is located in C:\Python26\Lib\site-packages\django-1.2.5-py2.6.egg\django and installed from source it's located in C:\Python26\Lib\site-packages\django
In fact when I'm using easy_install all installed modules are working without a problem, the only problem is that eclipse can't locate where is the source and gives me a false unresolved import errors
Where I'm wrong?
I'm assuming that eclipse does not search the egg files for source. Eggs, like jar files in Java, are just zipfiles of python code with some included metadata.
You'll also note that in site-packages you've got easy-install.pth and setuptools.pth files. Those files are parsed by python and used to add other directories and egg files to your PYTHONPATH (import sys; sys.path) so that Python can find the code in those locations. Eclipse isn't seeing those imports as valid because it is most likely not setup to take pth files into account.
To get Eclipse to recognize that Django is really installed you may want to try removing your easy_installed django package and reinstalling it with:
easy_install --always-unzip django
That way rather than installing a compressed egg file you'll have a normal package directory that eclipse should have a fairly easy time opening.
Alternatively, in your screenshot above it looks like you may just need to explicitly add each egg file you want eclipse to use.

Categories

Resources