简体   繁体   中英

Making Packages Available Outside PyCharm (Python3)

I have a program that imports the selenium package. It runs fine inside pyCharm but would not run on command prompt, saying "No module named selenium" (Windows 7). Is there an easy way to get all the setup in pyCharm and make them available in the command prompt?

This is because you have imported the packages under a virtual environment(venv) . Therefore the package imports are valid only for the virtual environment. So in order to work it globally you have to install it via command prompt without activating a venv.

The other poster is right in saying this issue is due to using a venv. To access this from the command prompt go into your configuration settings in PyCharm and get the path for your python interpreter. It will look something like "C:\\users\\project\\scripts\\python.exe" From the cmd run:

"Path to interpreter in quotes" "<path to your file>"

This will run your script using the settings for your venv.

If you will be using it frequently use a variable to avoid typing it repeatedly.

>set inter="path to your venv"
>%inter% " <Your script>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM