Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-30-2020, 11:47 AM
etalkishere etalkishere is offline
Registered User
 
Join Date: Sep 2015
Posts: 15
ImportErrorError: No module named

Hi,
I am trying to run a python script on my new Mac and got the following error. Is there any configuration I need to set in CRT? I have a macOS Catalina version 10.15.7, python 2.74, and also 3.8.1 installed on my Mac. The module requests is already installed, along with python. I am running zsh for the Mac CLI. Thanks.

ImportError

Error: No module named requests
File: /Users/xyz/scripts/script.py
Line: 18

import requests


~ > pip freeze | grep requests 12:10:53 PM
requests==2.24.0

~ > python -V 12:44:41 PM
Python 3.8.1
~ >
Reply With Quote
  #2  
Old 09-30-2020, 01:40 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi etalkishere,

The current release of SecureCRT (v8.7.x) does not support Python 3.

What are the results if you use Python 2.7?

I have added this thread to a feature request in our product enhancement database to add support for Python 3 for SecureCRT/Mac and SecureCRT/Linux. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14299 in the subject line or use this form from the support page of our website.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 11-20-2020, 03:23 PM
cboyack cboyack is offline
VanDyke Technical Support
 
Join Date: Apr 2020
Location: Albuquerque, NM
Posts: 129
Hi etalkishere,

We're happy to announce that Python 3 support is now available in the beta 3 build of SecureCRT version 9.0!

Please feel free to test it out!
__________________
Thanks,
--Cameron

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #4  
Old 03-13-2021, 08:00 AM
etalkishere etalkishere is offline
Registered User
 
Join Date: Sep 2015
Posts: 15
Sorry, I missed this reply until now

I have a follow-up question. We have a 2.7 python script that is currently running fine with Secure CRT version 8.x. I want to port the script to python 3.8.x and work with Secure CRT 9.x. I am using pycharm PE as IDE, but of course, I can't debug it in pycharm because pycharm won't recognize CRT modules/objects.

How do I debug my python 2 or 3 script inside Secure CRT environment? How do I make CRT recognize the python modules that part of my python script (ie, when I run the python script via Scrip->Run, there is a ModuleNotFoundError error, from one of my script's import statement)?

Is there any documentation in this forum for those things?

I am new to this, so any guidance and feedback would be much appreciated. Looking forward to hear back soon.

Quote:
Originally Posted by cboyack View Post
Hi etalkishere,

We're happy to announce that Python 3 support is now available in the beta 3 build of SecureCRT version 9.0!

Please feel free to test it out!
Reply With Quote
  #5  
Old 03-15-2021, 11:51 AM
cboyack cboyack is offline
VanDyke Technical Support
 
Join Date: Apr 2020
Location: Albuquerque, NM
Posts: 129
Hi etalkishere,

I apologize that I didn't include a link to our How-To post on using Python 3.8 with SecureCRT 9.0 in my announcement a few months back. First off, would you please take a look through that post to ensure all of the proper steps for using Python 3.8 with SecureCRT have been taken?

Once you've followed all of the steps in that How-To post, and if you're still unable to import modules with your script after making those changes, would you be so kind as to add the following lines of code to your script (just under your current script header) and share the results?

Code:
import sys
import platform
crt.Dialog.MessageBox(
    "sys.version_info:\r\n{}\r\n\r\nsys.version:\r\n{}\r\n\r\nsys.hexversion:\r\n{}\r\n\r\nplatform.python_version:\r\n{}".format(
        sys.version_info,
        sys.version,
        sys.hexversion,
        platform.python_version()))

I've also added this post to a feature request on your behalf for an option to add a built-in python script debugger to SecureCRT. We'll post notification on this thread should such an option ever be implemented.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14299 in the subject line or use this form from the support page of our website.
__________________
Thanks,
--Cameron

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by cboyack; 03-15-2021 at 11:55 AM. Reason: Added feature request information
Reply With Quote
  #6  
Old 03-15-2021, 01:48 PM
etalkishere etalkishere is offline
Registered User
 
Join Date: Sep 2015
Posts: 15
Hi cboyack, thanks for the response. I did follow instructions on that url.

Here is the output.



Quote:
Originally Posted by cboyack View Post
Hi etalkishere,

I apologize that I didn't include a link to our How-To post on using Python 3.8 with SecureCRT 9.0 in my announcement a few months back. First off, would you please take a look through that post to ensure all of the proper steps for using Python 3.8 with SecureCRT have been taken?

Once you've followed all of the steps in that How-To post, and if you're still unable to import modules with your script after making those changes, would you be so kind as to add the following lines of code to your script (just under your current script header) and share the results?

Code:
import sys
import platform
crt.Dialog.MessageBox(
    "sys.version_info:\r\n{}\r\n\r\nsys.version:\r\n{}\r\n\r\nsys.hexversion:\r\n{}\r\n\r\nplatform.python_version:\r\n{}".format(
        sys.version_info,
        sys.version,
        sys.hexversion,
        platform.python_version()))

I've also added this post to a feature request on your behalf for an option to add a built-in python script debugger to SecureCRT. We'll post notification on this thread should such an option ever be implemented.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14299 in the subject line or use this form from the support page of our website.
Attached Images
File Type: png pic.png (10.4 KB, 154 views)

Last edited by cboyack; 03-15-2021 at 01:59 PM. Reason: Please see this How-To in order to properly embed images: https://forums.vandyke.com/showthread.php?t=14212
Reply With Quote
  #7  
Old 03-15-2021, 02:47 PM
cboyack cboyack is offline
VanDyke Technical Support
 
Join Date: Apr 2020
Location: Albuquerque, NM
Posts: 129
Hi etalkishere,

Thanks for running through those steps to verify that you're running Python 3.8 successfully. The problem at this point is more of a Python problem than a SecureCRT problem, FYI.

At this point, when someone is running Python 3.8 without issue, but an external python module is not found, it's usually because the python "path" doesn't include any folders in which the external module is located. In these cases, one option that you might try is to use the following line of code in your script...

Code:
sys.path.append('/path/to/search')
...to add the names of directories in which you want Python to search for your specific imported modules for use in that particular script.

Alternatively, you could add the module-containing directories to your PYTHONPATH environment variable, which would then be inserted into sys.path whenever Python is called.

Does either of the above options work for you?
__________________
Thanks,
--Cameron

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:19 AM.