Python Forum
Environment seems to keep losing references
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Environment seems to keep losing references
#1
I’m new to Python and am using Scrapy, ProxyChecker pandas, urllib, et. And using VS Code. When I first set things up and started coding this project all worked OK. But as time goes on I started to get errors such as:

No module named ‘ycurl’
Or
DLL load failed while importing pycurl: The specified module could not be found…. From proxy_checker import ProxyChecker

Other times I get similar errors for Scrapy or pandas. I setup my projects using this:

>python -m venv env

And then I install the above libraries using pip install. Sometimes activating the environment fixes things:

>Scripts\activate

Other times I have to close VS Code, other times I have to reboot and sometimes nothing works at all.
I have been developing on the MS stack for many years and I don’t know if there’s a conflict with the MS stuff and the python world.

Can anyone recommend how to make this more stable?

Thank you
Reply
#2
If using a virtual environment, it must be active when installing packages, otherwise you will install to a different python version.

you can determine where that is by:
  1. Then to verify where that python resides where you expect from system command line:
    pip -V
    Output:
    pip 21.0.1 from .../Projects/projects/ABCD/A/ArduinoPython/venv/lib/python3.9/site-packages/pip (python 3.9)
  2. Next check interpreter (again from system command line):
    python -V
    Which should return something similar to:
    Output:
    Python 3.9.2
  3. The first time you start start the project in VSCode, you will also have to tell
    VSCode where python resides.
    To do this, from within VSCode, type command Ctrl-Shift-P
    highlight and select Python: Select Interpreter
    From the drop-down select:
    Python3.9.2 64 bit ('venv')
    ./venv/bin/python
  4. Finally check the list of packages installed in your virtual environment:
    with Virtual environment activated in VSCode terminal, issue command:
    pip list
    if you are missing any packages, re-install (with virtual environment activated) using pip.
  5. VSCode and you environment should now be set, and will come up with proper interpreter when started.
  6. One anomaly that I experience (I haven't found out how to prevent this) is that when I last used VSCode on a particular project, and exit that project with terminals still open, the next time i load the project, the terminal will come up as before, but not in virtual mode. If this happens, close the terminal window and start a new one from the VSCode menu.
Reply
#3
thank you, that answered the question.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  losing memory antioch 1 1,735 Jan-20-2021, 05:29 AM
Last Post: antioch
  Winning/Losing Message Error in Text based Game kdr87 2 2,927 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  SQL Alchemy dynamic class - declarative_base losing attributes mrdominikku 4 3,676 Jan-10-2020, 06:46 PM
Last Post: mrdominikku
  assignments of function references Skaperen 3 2,315 Aug-15-2019, 11:12 AM
Last Post: fishhook
  Help with parameter variables losing value kofipython 4 3,130 Feb-24-2018, 11:48 AM
Last Post: Larz60+
  module functions and data references Skaperen 6 4,203 Jul-30-2017, 04:09 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020