WraithJT
WraithJT

Reputation: 3

Python: Cannot Run Script Outside of PyCharm (ImportError)

I am attempting to run a script that I have finished writing without having to launch PyCharm every time I run it.

However, I receive the following error when trying to run it from my command-line in Windows 10:

Traceback (most recent call last):
  File "C:\Users\stuff\bot.py", line 5, in <module>
    import irc.bot
ImportError: No module named irc.bot

My folder structure to get to irc.bot looks like:

main folder
--venv
----lib
------site-packages
--------irc
----------bot.py

I'm fairly certain the issue is the virtual environment configuration, but I'm not sure how to get around that in a batch file to launch my script.

Upvotes: 0

Views: 709

Answers (2)

Owen Campbell
Owen Campbell

Reputation: 632

In order for python to recognize the module, first enter the virtual environment using the script located at:

venv\Scripts\activate

Upvotes: 2

Madhur Yadav
Madhur Yadav

Reputation: 723

I've faced a similar issue.

Upgrade the version of pip, wheel and setuptools in your virtualenv and afterwards try to install irc.

Hope that it works.

Upvotes: 0

Related Questions