<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Access arcpy on Linux in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791173#M1593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more note: I tried a little more with Visual Studio Code, and it looks like at some point, they will fix this upstream by activating the environment prior to using it with Conda environments. Currently, they just call python.exe without activation, they have a few issues open on their repository about this, such as &lt;A class="link-titled" href="https://github.com/Microsoft/vscode-python/issues/2067" title="https://github.com/Microsoft/vscode-python/issues/2067"&gt;Debugger not activating Anaconda environments · Issue #2067 · Microsoft/vscode-python · GitHub&lt;/A&gt;&amp;nbsp;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to try and make this work in Visual Studio Code today without any additional setup of environment variables, you could also set them up manually with VScode (see &lt;A class="" href="https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file" title="https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file"&gt;Configuring Python Environments in Visual Studio Code&lt;/A&gt; ) , but it's probably easiest to run code from within the active environment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Aug 2018 19:48:17 GMT</pubDate>
    <dc:creator>ShaunWalbridge</dc:creator>
    <dc:date>2018-08-31T19:48:17Z</dc:date>
    <item>
      <title>Access arcpy on Linux</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791171#M1591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have installed ArcGIS Server 10.6.1 on Linux and followed the instruction &lt;A href="https://enterprise.arcgis.com/en/server/latest/administer/linux/linux-python.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt; to create&amp;nbsp;a&amp;nbsp;conda&amp;nbsp;environment named arcgis with Python 3.6. Using the shell, I can activate the conda&amp;nbsp;env and import arcpy&amp;nbsp;successfully. However, the conda env does not work with any IDE (e.g., PyCharm, VS Code) or Jupyter Notebook. See below the message I got when trying to import arcpy&amp;nbsp;in Jupyter Notebook. Any help will be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #e75c58;"&gt;---------------------------------------------------------------------------
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #e75c58;"&gt;error&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Traceback (most recent call last)
&lt;SPAN class="" style="color: #00a250;"&gt;&amp;lt;ipython-input-1-5467a3dc9fe3&amp;gt;&lt;/SPAN&gt; in &lt;SPAN class="" style="color: #60c6c8;"&gt;&amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #208ffb;"&gt;()
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #00a250;"&gt;----&amp;gt; 1&lt;/SPAN&gt;&lt;SPAN class="" style="color: #e75c58;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #00a250;"&gt;import&lt;/SPAN&gt; arcpy 
&lt;SPAN class="" style="color: #00a250;"&gt;/opt/anaconda/envs/arcgis/lib/python3.6/site-packages/arcpy/__init__.py&lt;/SPAN&gt; in &lt;SPAN class="" style="color: #60c6c8;"&gt;&amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #208ffb;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="" style="color: #007427; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
68&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="" style="color: #00a250;"&gt;raise&lt;/SPAN&gt; ImportError&lt;SPAN class="" style="color: #208ffb;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #208ffb;"&gt;"arcpy needs to run within an active ArcGIS Conda environment"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #208ffb;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #007427; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
69&lt;/SPAN&gt; &lt;SPAN class="" style="color: #00a250;"&gt;else&lt;/SPAN&gt;&lt;SPAN class="" style="color: #208ffb;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="" style="color: #00a250;"&gt;---&amp;gt; 
70&lt;/SPAN&gt;&lt;SPAN class="" style="color: #e75c58;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #00a250;"&gt;import&lt;/SPAN&gt; _initagsenv&lt;SPAN class="" style="color: #007427; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
71&lt;/SPAN&gt; &lt;SPAN class="" style="color: #007427; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
72&lt;/SPAN&gt; &lt;SPAN class="" style="color: #00a250;"&gt;from&lt;/SPAN&gt; arcpy&lt;SPAN class="" style="color: #208ffb;"&gt;.&lt;/SPAN&gt;geoprocessing &lt;SPAN class="" style="color: #00a250;"&gt;import&lt;/SPAN&gt; gp 
&lt;SPAN class="" style="color: #e75c58;"&gt;error&lt;/SPAN&gt;: WSLib: failed initializing arcpy. Check if environment was activated correctly.
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #e75c58;"&gt;---------------------------------------------------------------------------
&lt;/SPAN&gt;

arcpy only works in Console &lt;/PRE&gt;&lt;IMG alt="arcpy-linux" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/420690_Screenshot_20180828_170034.png" /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:04:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791171#M1591</guid>
      <dc:creator>QiushengWu2</dc:creator>
      <dc:date>2021-12-12T09:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Access arcpy on Linux</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791172#M1592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Quisheng,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great to hear you're trying out the native ArcPy project, I'd be happy to help you. It should work for anything that's running inside the conda environment, you'll just need to run the commands inside the activated environment. Here's IPython started this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;(arcpy-native) arcgis@ubuntu:/$ ipython&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;Type 'copyright', 'credits' or 'license' for more information&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;In [1]: import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;In [2]: arcpy.GetInstallInfo()['Version']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;Out[2]: '10.6.1'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should also work well for Jupyter Notebooks and tools like Spyder, which can be installed into the environment. The story for other external tools is still a little complicated, the native ArcPy interface has to initialize system environment variables in order to operate. The script that executes on startup is available in &lt;SPAN style="font-family: terminal, monaco, monospace; font-size: 13px;"&gt;$CONDA_PREFIX/etc/conda/activate.d/arcgis-server-10.6.1-py3-env_vars.sh&lt;/SPAN&gt; if you'd like to take a look. The simpler way to get this along with your IDE is to start your IDE from within the active environment, so e.g. type `code` after activating the environment to start Visual Studio Code [note: I haven't tested this, but it should inherit the calling environment on creation]. Alternatively, you could create a bash script that first sourced that file. This is necessary because tools that call into ArcPy need to initialize the server pieces internally which are used for their dependent calls. We are looking at simplifying this for a future release, but hopefully that's enough information to get you started.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Shaun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2018 18:31:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791172#M1592</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2018-08-31T18:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Access arcpy on Linux</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791173#M1593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more note: I tried a little more with Visual Studio Code, and it looks like at some point, they will fix this upstream by activating the environment prior to using it with Conda environments. Currently, they just call python.exe without activation, they have a few issues open on their repository about this, such as &lt;A class="link-titled" href="https://github.com/Microsoft/vscode-python/issues/2067" title="https://github.com/Microsoft/vscode-python/issues/2067"&gt;Debugger not activating Anaconda environments · Issue #2067 · Microsoft/vscode-python · GitHub&lt;/A&gt;&amp;nbsp;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to try and make this work in Visual Studio Code today without any additional setup of environment variables, you could also set them up manually with VScode (see &lt;A class="" href="https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file" title="https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file"&gt;Configuring Python Environments in Visual Studio Code&lt;/A&gt; ) , but it's probably easiest to run code from within the active environment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2018 19:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/791173#M1593</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2018-08-31T19:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Access arcpy on Linux</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/1271170#M8544</link>
      <description>&lt;P&gt;It's easy to reproduce and it's not related with VS Code. Steps to reproduce:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;- run `docker run -it --rm continuumio/anaconda3 bash`
- create new environment by executing:
```bash
conda create -n arcgis -c esri python=3.7 anaconda arcgis-server-py3
```
- activate environment by executing:
```bash
conda activate arcgis
```
- start `python3`:
```bash
python3
```
- try import arcpy:
```python
import arcpy
```

Result is:
```
Python 3.7.16 (default, Jan 17 2023, 22:20:44)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import arcpy
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "/opt/conda/envs/arcgis/lib/python3.7/site-packages/arcpy/__init__.py", line 75, in &amp;lt;module&amp;gt;
    import _initagsenv
_initagsenv.error: Xvfb: failed initializing arcpy. Check if environment was activated correctly.
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 21:27:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/1271170#M8544</guid>
      <dc:creator>rkraujutis_hb</dc:creator>
      <dc:date>2023-03-23T21:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Access arcpy on Linux</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/1347260#M9266</link>
      <description>&lt;P&gt;I use VS Code to debug arcpy on Linux. It can be finicky and I sometimes get the "Xvfb: failed initializing arcpy. Check if environment was activated correctly." error when importing arcpy. The way I use VS Code to debug and run scripts is basically this:&lt;/P&gt;&lt;P&gt;1) I create Python unit tests to step into the arcpy script. I either run proper unit test or just step into and run main() if I want to run the entire script.&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; In VS Code I open an integrated bash terminal and copy and paste the following lines of bash code into it&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;export PATH="$PATH:/home/arcgis/anaconda3/bin"&lt;BR /&gt;export ARCGISHOME=/opt/esri/arcgis/server&lt;BR /&gt;source activate arcpy3&lt;/P&gt;&lt;P&gt;3) Then in VS Code I make sure the Python interpreter from my arcpy3 conda environment is selected as the Python interpreter.&lt;/P&gt;&lt;P&gt;4) I open the Python unit test file and in VS Code Debug I run the "Python: Current File (Integrated Terminal)" debug configuration to step into a breakpoint.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VidmasKondratas_0-1699462213588.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85387iE3006CF61DA521DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VidmasKondratas_0-1699462213588.png" alt="VidmasKondratas_0-1699462213588.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 16:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-arcpy-on-linux/m-p/1347260#M9266</guid>
      <dc:creator>VidmasKondratas</dc:creator>
      <dc:date>2023-11-08T16:54:10Z</dc:date>
    </item>
  </channel>
</rss>

