Jump to content

installing modules from within a script

Recommended Posts

Posted (edited)

approachVectorWorks : v2020

MacOSX        : 10.14.6




I have used until now sucessfully the following code snippet to install missing modules:


see also this forum entry:  "PIL python image library for vw 2018"


vModule = 'mymoduleToimport'

pip.main(['install', '--upgrade', '-v', vModule])

# or 

vVW_AppUserPy_folder = '/Users/myuser/Library/Application\ Support/VectorWorks/2020/PythonExternals'

pip.main(['install', '--upgrade', '-v', vModule, '--target', vVW_AppUserPy_folder])

This works for most modules.  For some modules (e.g. pyspatial) this approach is not working and instead a second instance of the VectorWorks.app is started without any error (only verbose console output), but those modules are finally not installed. As far as I can see, those modules that are not working are calling the setup.py script. Is there any way to suppress this behavior?


While "debugging" I learned, that in PIP > version 10 (actual PIP version is version 20, and in VectorWorks v2020 version 8.1 is installed by default), the pip.main() function is removed and the following construct should be used:


vPip_proc = subprocess.run([sys.executable, '-m', 'pip', 'install', '--upgrade', '-v', vModule, '--target', vVW_AppUserPy_folder ])

vPip_proc_exit_code = vPip_proc.returncode
vPip_proc_sdtout = vPip_proc.stdout
vPip_proc_sdterr = vPip_proc.stderr


Unfortunately this approach is not working at all for all python modules. Every time a second instance of the VectorWorks.app is started without any error and output and no module is installed.


I would appreciate any hint or suggestion how to solve this problem. Many thanks in advance,






Edited by relume
added information

Share this post

Link to post
Posted (edited)

sry, oversaw that you already found doms post.

Edited by PatW

Share this post

Link to post



in the following there is the VW log output of installing the module "pyspatial" (the same with "rtree") that does not work with the pip.main() approach and starts a setup.py "process" and a second instance of the VectorWorks.app:



  Starting new HTTPS connection (1): pypi.org
  https://pypi.org:443 "GET /simple/pyspatial/ HTTP/1.1" 304 0
  Analyzing links from page https://pypi.org/simple/pyspatial/
    Found link https://files.pythonhosted.org/packages/e2/a4/3d79183abfa1f898cfb48d858c7b31af158c4a8195f4a68acdc7f2262f26/pyspatial-0.1.0.tar.gz#sha256=0a887170be86e6ef6ef6bab8afa416cd876f9e2ddd3bef50f08213074bcf62d3 (from https://pypi.org/simple/pyspatial/), version: 0.1.0
    Found link https://files.pythonhosted.org/packages/4d/4c/389f48ccacbc3914e0f3e4cc33848b090a12917b4dfec9fa6622e9425d7c/pyspatial-0.1.1.tar.gz#sha256=245c2c8d9c5ad436a01d743b7f1b40067aaa5b998178f52284affb1dd269150b (from https://pypi.org/simple/pyspatial/), version: 0.1.1
    Found link https://files.pythonhosted.org/packages/26/93/adc918fa271de29f14b17de01409a29bbeb54e3ee18578ba999809787726/pyspatial-0.1.2.tar.gz#sha256=fbcec18df8d43d870e42a56f83e6286542d1bcf63bfa1e4070cb4d5dfd6a9ce6 (from https://pypi.org/simple/pyspatial/), version: 0.1.2
    Found link https://files.pythonhosted.org/packages/be/8e/38680a60c87da016a67e7674088562e8cfbb1d478ef75759a2963de7fd82/pyspatial-0.1.4.tar.gz#sha256=d97fb8ca47684cd20659785a541f0e32075cdc23e134761d34e199c7aef5711c (from https://pypi.org/simple/pyspatial/), version: 0.1.4
    Found link https://files.pythonhosted.org/packages/b7/9d/694cf404ea5abb10117b0d9aebaf610cddbaaf1bdc3202aa0b730d1e472f/pyspatial-0.2.1.tar.gz#sha256=612e2ee010558d14c8efaa70dad43c7c147e5b6e79eedc6eb965d61c6b568d46 (from https://pypi.org/simple/pyspatial/), version: 0.2.1
    Found link https://files.pythonhosted.org/packages/eb/b3/57d3d0fc106bb1d22a9ca9b6055a2865e2f5ee9c897e3b8eb2ec91cdf23a/pyspatial-0.2.3.tar.gz#sha256=2ea43da81fa2094de99ade462430bff298778be3ca02bfc3eb5dd69e911491fe (from https://pypi.org/simple/pyspatial/), version: 0.2.3
    Found link https://files.pythonhosted.org/packages/27/c8/279807519a8c76115c5bb38a454784b69513c889e50afee874470f884223/pyspatial-0.2.4.tar.gz#sha256=387e26cf08b02504ebec0ec1c137aa4331d4818ae9738210f19d40aa3261e8c9 (from https://pypi.org/simple/pyspatial/), version: 0.2.4
  Using version 0.2.4 (newest of versions: 0.1.0, 0.1.1, 0.1.2, 0.1.4, 0.2.1, 0.2.3, 0.2.4)
  Looking up "https://files.pythonhosted.org/packages/27/c8/279807519a8c76115c5bb38a454784b69513c889e50afee874470f884223/pyspatial-0.2.4.tar.gz" in the cache
  Current age based on date: 152800
  Freshness lifetime from max-age: 365000000
  The response is "fresh", returning cached response
  365000000 > 152800
  Using cached https://files.pythonhosted.org/packages/27/c8/279807519a8c76115c5bb38a454784b69513c889e50afee874470f884223/pyspatial-0.2.4.tar.gz
  Downloading from URL https://files.pythonhosted.org/packages/27/c8/279807519a8c76115c5bb38a454784b69513c889e50afee874470f884223/pyspatial-0.2.4.tar.gz#sha256=387e26cf08b02504ebec0ec1c137aa4331d4818ae9738210f19d40aa3261e8c9 (from https://pypi.org/simple/pyspatial/)
  Running setup.py (path:/private/var/folders/nx/hzd6xdlj62d6xnh9n63x3cwc000mh8/T/pip-build-huwr1_vk/pyspatial/setup.py) egg_info for package pyspatial
    Running command python setup.py egg_info
    2020-03-07 10:22:20.657 Vectorworks[14776:14547727] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
    2020-03-07 10:22:27.183 Vectorworks[14776:14547727] Attempt to load executable of a type that cannot be dynamically loaded for CFBundle 0x7fc97843d520 </Applications/Vectorworks 2020/Plug-Ins/SketchUpWorker.vwlibrary> (executable, not loaded)
    [0307/102229.600319:WARNING:resource_bundle.cc(353)] locale_file_path.empty() for locale de-CH
    [0307/102229.600668:ERROR:main_delegate.cc(671)] Could not load locale pak for de-CH
    [0307/102229.606890:WARNING:resource_bundle.cc(548)] locale resources are not loaded


    [0307/102229.612772:ERROR:proxy_service_factory.cc(116)] Cannot use V8 Proxy resolver in single process mode.
    *   Trying
    * TCP_NODELAY set
    * Connected to vectorworks-hilfe.computerworks.eu ( port 80 (#0)
    > HEAD /2020/index.htm HTTP/1.1
    Host: vectorworks-hilfe.computerworks.eu
    Accept: */*

    < HTTP/1.1 200 OK
    < Date: Sat, 07 Mar 2020 09:22:32 GMT
    < Server: Apache/2.4.41
    < Last-Modified: Tue, 14 Jan 2020 14:51:47 GMT
    < ETag: "6c4a-59c1abb2fc496"
    < Accept-Ranges: bytes
    < Content-Length: 27722
    < Content-Type: text/html
    * Connection #0 to host vectorworks-hilfe.computerworks.eu left intact
    2020-03-07 10:22:36.016 Vectorworks[14776:14547727] Reachability Flag Status: -R ------- networkStatusForFlags
    Application start      : 03/07/20 at 10:22:37



by this following part of the sequence (snippet from above log) the second VectorWorks.app is started up:



   Running setup.py (path:/private/var/folders/nx/hzd6xdlj62d6xnh9n63x3cwc000mh8/T/pip-build-huwr1_vk/pyspatial/setup.py) egg_info for package pyspatial
    Running command python setup.py egg_info



Many thanks for any hint,




P.S. the Marionette.VerifyOrGetLib() approach does not work really, if you do want to install libs/modules in more generalistic way like this e.g. "pip.main(install --upgrade 'dateutil>=2.5.0' and without passing the ressource URL as it is needed in Marionette.VerifyOrGetLib()



Share this post

Link to post



I have posted some (final) findings on the other  topic pil-python-image-library-for-vw-2018.


As for the problem with the before mentioned "pyspatial" module the problem is inherent to the actual version of the "pyspatial" module and the pip version that module is installed with. Other modules that use setup.py "e.g. rtree" can be installed with above (final) findings without any problems.



Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...