I'm using software that is built for Windows with no version for Linux. They have dedicated Python library called ArcPy, that has scripts of all of the tools available in this software.
On Ubuntu 16.04 I'm trying to import this package to my Python, so I can use all those scripts. Inside /usr/local/lib/python2.7/site-packages I created Desktop.pth into which I echoed:
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/bin
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/arcpy
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/ArcToolBox/Scripts
Now entering Python shell and typing import arcpy returns ImportError: No module named arcpy. I know I typed the paths with correct escaping, because I can cd them.
Is it a correct way of importing Python packages across OSs? What went wrong here?
You can not use arcpy unless, either ArcGIS Server or ArcGIS engine is installed in the machine. ArcPy does not work without the binaries.
Related
I'm building a C++ python module on MacOS.
On my machine I have python, installed in directory /Library/Frameworks/Python.framework/Versions/3.9. I'm specifing python includes directory as -I/Library/Frameworks/Python.framework/Versions/3.9/Headers and libraries directory as -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9.
So it builds good and runs good on my machine and other machines, where python is installed into /Library/Frameworks/Python.framework/Versions/3.9.
But when I move my library to machine, where python is installed into another folder, like /usr/local/Cellar/python#3.9/3.9.12/Frameworks/Python.framework/Versions/3.9, I'm getting import module error.
otool -L _mymodule.so command returns hardcoded absolute path to /Library/Frameworks/Python.framework/Versions/3.9. I know, that I can change the path using install_name_tool, but I don't want to ask and explain my module users to do that, as well as to make a symlink.
How can I make module more portable and python install path independent?
I'm installing a package (cx_Oracle), and the documentation says:
Make sure you are not using the bundled Python. This has restricted
entitlements and will fail to load Oracle client libraries.
I'm wondering: how do I tell if my Python installation (if I did not install it) is "bundled" or not?
Normally in MAC OS python comes along with installation of OS itself that means python package included in OS files also called as bundled python. You can check if the python you are using is bundled or not by
which python
On mac os
you should get output like if it's a bundled python
/usr/bin/python
when you want to get the path of externally installed python by
which python3
The only difference is
When you type
python
in terminal it launches pre-installed or bundled python.
If you type
python3
in terminal it launches externally installed python in this cases what the oracle documentation is recommended
I'm trying to run a script that was written with python 2.7, using some libraries that I've installed on my Windows machine - among them numpy scipy, scikit, requests and others.
Now I need to use a COM object dll, so I am writing an IronPython script that loads that dll. However when I try to use or import the python 2.7 code, I get import errors:
ImportError: No module named requests
How can I use that python 2.7 code I wrote with IronPython? I could run the script with the python 2.7 interpreter through a system command, but that would mean a big waste of time.
Any help would be appreciated.
IronPython is written in C#, so you can't (easily) use C Extensions for cPython on it.
There is a port of numpy and scipy for the Microsoft .Net environment.
For pure python packages and modules, appending to sys.path allows you to do imports.
Did you python setup.py install your own code? Otherwise it won't be in the installations site-packages and you should add your project's directory to sys.path.
There is an additional problem with requests, an issue with supported encodings (https://ironpython.codeplex.com/workitem/4565) prevents that from working. The issue has been open for ages.
If you can be more specific about your code and setup, other people could chime in with more suggestions.
I am attempting to install IronPython. I downloaded the stable 2.7.5 installer from here:
http://ironpython.net/download/
I ran the installer and all is well. It is not located at:
C:\Program Files (x86)\IronPython 2.7
I have a previous installation of Python 2.7 from my ArcGIS installation, which packages and installs python along with it. My installation location for python is:
C:\Python27\ArcGIS10.2
So, when I test and:
import clr
I receive and error:
ImportError: No module named clr
My Environment Variable Path names are all correct.
I'm just wondering if python IDLE knows where to grab IronPython, or did I install wrong?
The name of the IronPython intepreter is ipy.exe. If you not starting this, you are not using IronPython. So you should see the application name in the window title and when starting the shell. When you use it in an IDE, you should tell the IDE that you are using IronPython, if it support it. Just setting some environment variables will not help. If you are targeting the correct directory and ipy.exe will be used, everything should work just fine.
I'm trying to install the module mySQLdb on a windows vista 64 (amd) machine.
I've installed python on a different folder other than suggested by Python installer.
When I try to install the .exe mySQLdb installer, it can't find python 2.5 and it halts the installation.
Is there anyway to supply the installer with the correct python location (even thou the registry and path are right)?
did you use an egg?
if so, python might not be able to find it.
import os,sys
os.environ['PYTHON_EGG_CACHE'] = 'C:/temp'
sys.path.append('C:/path/to/MySQLdb.egg')