#๐Ÿ”’ ModuleNotFoundError: No module named 'docx'

61 messages ยท Page 1 of 1 (latest)

drowsy hedgeBOT
#

@thin dagger

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

alpine mirage
#

once you have created a venv you need to activate it, have you done that?

#

when you create a venv it makes a folder, inside the folder is another folder "scripts" and the activation script is in there generally. I think there are different scripts for different shells (powershell vs cmd). Once you get it activated, libraries will install to the venv folder and you will activate it to use them moving forward

hasty bay
#

if you go into your system environment variables, you can create PIP_REQUIRE_VIRTUALENV

#

this will stop you from pip installing outside of a venv

alpine mirage
#

that's interesting

hasty bay
#

(tho I actually do not have pip installed on global at all, so it's not useful for me)

#

the benefit of using the envvar is that you can simply remove it later if you wanna use pip on global

thin dagger
#

can't find the folder ๐Ÿ˜ญ

hasty bay
#

what folder?

alpine mirage
#

the scripts folder

hasty bay
#

o

thin dagger
hasty bay
#

it may be hidden

alpine mirage
#

maybe in bin?

hasty bay
#

try running it from your terminal

hasty bay
#

or maybe the Windows ones look different

#

windows venv venv has Include, Lib, and Scripts

thin dagger
hasty bay
#

what did you use to create the venv?

alpine mirage
#

activating a venv has nothing to do with python

#

have a look at

thin dagger
#

Idk, a coworker did, but he doesn't work anymore lol

#

๐Ÿ˜ญ

hasty bay
#

is the venv fresh?

alpine mirage
#

what kind of project?

hasty bay
#

like, it wouldn't be an issue to just make a new one?

alpine mirage
#

possible it's on conda

#

different process if that rings any bells

#

only ever seen that used for data science and ML, is why I ask what kind of project

#

I'm probably distracting you though, Jay is right, it's really not that hard to make a new venv if you know what libraries you need

thin dagger
#

hmm i'm automating some emails, they send me the data, I put it in the app and it returns a docs filled with the data

#

cause i need to write a lot of certificates every day

#

I'll make a new venv then

hasty bay
#

on a POSIX system, the activate is in bin

thin dagger
#

Honestly, I can't make it work, I'll just ask someone in the office tomorrow, I'm just an intern so

random forge
#

here is a very good tutorial/article/blog post about how to use venvs both in the shell on different systems and vscode or pycharm if you use one of those https://realpython.com/python-virtual-environments-a-primer/

In this tutorial, you'll learn how to use a Python virtual environment to manage your Python projects. You'll also gain a deep understanding of the structure of virtual environments created with the venv module, as well as the rationale behind using virtual environments.

thin dagger
#

thank youu

random forge
#

as the article states, you need to run

source venv/bin/activate
```to activate your venv, then you can `pip install` the library
thin dagger
#

Ohh i'll tryy now

#

ok, so

#

It says this:
Requirement already satisfied: python-docx in /opt/homebrew/lib/python3.11/site-packages (1.2.0)

#

I think it's not downloading in the venv

#

but it says (venv)

#

when i type

random forge
#

the article covers all of this and a lot more, it's very long and indepth so you might not want to read it all, but you can check the table of content at the start and read the parts that you need or find interesting

random forge
thin dagger
#

yup

#

(venv) myname foldername %

#

like this

random forge
#

that would indicate that the venv is activated for that shell instance

thin dagger
#

but it's still downloading outside the venv ๐Ÿ˜”

random forge
#

then it might be that it's not activated in your ide where you are trying to run it or write your code

thin dagger
#

Idk how but i asked an llm, gave some random code and now it worked

#

๐Ÿ’€ anyway thank you guys

drowsy hedgeBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.