Pycharm no module named ошибка

В Python может быть несколько причин возникновения ошибки ModuleNotFoundError: No module named ...:

  • Модуль Python не установлен.
  • Есть конфликт в названиях пакета и модуля.
  • Есть конфликт зависимости модулей Python.

Рассмотрим варианты их решения.

Модуль не установлен

В первую очередь нужно проверить, установлен ли модуль. Для использования модуля в программе его нужно установить. Например, если попробовать использовать numpy без установки с помощью pip install будет следующая ошибка:

Traceback (most recent call last):
   File "", line 1, in 
 ModuleNotFoundError: No module named 'numpy'

Для установки нужного модуля используйте следующую команду:

pip install numpy
# или
pip3 install numpy

Или вот эту если используете Anaconda:

conda install numpy

Учтите, что может быть несколько экземпляров Python (или виртуальных сред) в системе. Модуль нужно устанавливать в определенный экземпляр.

Конфликт имен библиотеки и модуля

Еще одна причина ошибки No module named — конфликт в названиях пакета и модуля. Предположим, есть следующая структура проекта Python:

demo-project
 └───utils
         __init__.py
         string_utils.py
         utils.py

Если использовать следующую инструкцию импорта файла utils.py, то Python вернет ошибку ModuleNotFoundError.


>>> import utils.string_utils
Traceback (most recent call last):
File "C:demo-projectutilsutils.py", line 1, in
import utils.string_utils
ModuleNotFoundError: No module named 'utils.string_utils';
'utils' is not a package

В сообщении об ошибке сказано, что «utils is not a package». utils — это имя пакета, но это также и имя модуля. Это приводит к конфликту, когда имя модуля перекрывает имя пакета/библиотеки. Для его разрешения нужно переименовать файл utils.py.

Иногда может существовать конфликт модулей Python, который и приводит к ошибке No module named.

Следующее сообщение явно указывает, что _numpy_compat.py в библиотеке scipy пытается импортировать модуль numpy.testing.nosetester.

Traceback (most recent call last):
   File "C:demo-projectvenv
Libsite-packages
         scipy_lib_numpy_compat.py", line 10, in
     from numpy.testing.nosetester import import_nose
 ModuleNotFoundError: No module named 'numpy.testing.nosetester'

Ошибка ModuleNotFoundError возникает из-за того, что модуль numpy.testing.nosetester удален из библиотеки в версии 1.18. Для решения этой проблемы нужно обновить numpy и scipy до последних версий.

pip install numpy --upgrade
pip install scipy --upgrade 

I have written a module (a file my_mod.py file residing in the folder my_module).
Currently, I am working in the file cool_script.py that resides in the folder cur_proj. I have opened the folder in PyCharm using File — open (and I assume, hence, it is a PyCharm project).

In ProjectView (CMD-7), I can see my project cur_proj (in red) and under «External Libraries» I do see my_module. In cool_script.py, I can write

from my_module import my_mod as mm

and PyCharm even makes suggestion for my_mod. So far so good.

However, when I try to run cool_script.py, PyCharm tells me
«No module named my_module»

This seems strange to me, because

A) in the terminal (OS 10.10.2), in python, I can import the module no problem — there is a corresponding entry in the PYTHONPATH in .bashrc

B) in PyCharm — Settings — Project cur_proj — Project Interpreter — CogWheel next to python interpreter — more — show paths for selected interpreter icon, the paths from PYTHONPATH do appear (as I think they should)

Hence, why do I get the error when I try to run cool_script.py? — What am I missing?

Notes:

  • I am not declaring a different / special python version at the top of cool_script.py
  • I made sure that the path to my_module is correct
  • I put __init__.py files (empty files) both in my_module and in cur_proj
  • I am not using virtualenv

Addendum 2015-Feb-25

When I go in PyCharm to Run — Edit Configurations, for my current project, there are two options that are selected with a check mark: «Add content roots to PYTHONPATH» and «Add source roots to PYTHONPATH«. When I have both unchecked, I can load my module.

So it works now — but why?

Further questions emerged:

  • What are «content roots» and what are «source roots»? And why does adding something to the PYTHONPATH make it somehow break?
  • should I uncheck both of those options all the time (so also in the defaults, not only the project specific configurations (left panel of the Run/Debug Configurations dialog)?

I’m having trouble with using ‘requests’ module on my Mac. I use python34 and I installed ‘requests’ module via pip. I can verify this via running installation again and it’ll show me that module is already installed.

15:49:29|mymac [~]:pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages

Although I can import ‘requests’ module via interactive Python interpreter, trying to execute ‘import requests’ in PyCharm yields error ‘No module named requests’. I checked my PyCharm Python interpreter settings and (I believe) it’s set to same python34 as used in my environment. However, I can’t see ‘requests’ module listed in PyCharm either.

PyCharm Python interpreter settings

It’s obvious that I’m missing something here. Can you guys advise where should I look or what should I fix in order to get this module working? I was living under impression that when I install module via pip in my environment, PyCharm will detect these changes. However, it seems something is broken on my side …

CristiFati's user avatar

CristiFati

37.7k9 gold badges50 silver badges86 bronze badges

asked Jul 5, 2015 at 21:56

Martinecko's user avatar

1

In my case, using a pre-existing virtualenv did not work in the editor — all modules were marked as unresolved reference (running naturally works, as this is outside of the editor’s config, just running an external process (not so easy for debugging)).
Turns out PyCharm did not add the site-packages directory… the fix is to manually add it.

On Pycharm professional 2022.3

Open File -> Settings -> Python Interpreter, open the drop-down and pick «Show All…» (to edit the config) (1), right click your interpreter (2), click «Show Interpreter Paths» (3).

In that screen, manually add the «site-packages» directory of the virtual environment [looks like .../venv/lib/python3.8/site-packages (4) (I’ve added the «Lib» also, for a good measure); once done and saved, they will turn up in the interpreter paths.

the steps

The other thing that won’t hurt to do is select «Associate this virtual environment with the current project», in the interpreter’s edit box.

Gulzar's user avatar

Gulzar

22.5k23 gold badges104 silver badges186 bronze badges

answered Jan 6, 2019 at 7:50

Todor Minakov's user avatar

Todor MinakovTodor Minakov

18.9k3 gold badges55 silver badges59 bronze badges

5

If you are using PyCharms CE (Community Edition), then click on:

File->Default Settings->Project Interpreter

Screenshot: Interpretor Settings

See the + sign at the bottom, click on it. It will open another dialog with a host of modules available. Select your package (e.g. requests) and PyCharm will do the rest.

Gulzar's user avatar

Gulzar

22.5k23 gold badges104 silver badges186 bronze badges

answered Mar 3, 2017 at 1:04

user7650698's user avatar

user7650698user7650698

5294 silver badges2 bronze badges

2

This issue arises when the package you’re using was installed outside of the environment (Anaconda or virtualenv, for example). In order to have PyCharm recognize packages installed outside of your particular environment, execute the following steps:

Go to

Preferences -> Project -> Project Interpreter -> 3 dots -> Show All ->
Select relevant interpreter -> click on tree icon Show paths for the selected interpreter

Now check what paths are available and add the path that points to the package installation directory outside of your environment to the interpreter paths.

To find a package location use:

$ pip show gym
Name: gym
Version: 0.13.0
Summary: The OpenAI Gym: A toolkit for developing and comparing your reinforcement learning agents.
Home-page: https://github.com/openai/gym
Author: OpenAI
Author-email: gym@openai.com
License: UNKNOWN
Location: /usr/local/lib/python3.7/site-packages
...

Add the path specified under Location to the interpreter paths, here

/usr/local/lib/python3.7/site-packages

Then, let indexing finish and perhaps additionally reopen your project.

answered Jun 8, 2020 at 16:19

whiletrue's user avatar

whiletruewhiletrue

10.3k6 gold badges27 silver badges47 bronze badges

3

Open python console of your pyCharm. Click on Rerun.
It will say something like following on the very first line

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 52631 52632

in this scenario pyCharm is using following interpretor

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 

Now fire up console and run following command

sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -m pip install <name of the package>

This should install your package :)

answered Jun 1, 2016 at 18:22

Ketav Sharma's user avatar

0

Pycharm is unable to recognize installed local modules, since python interpreter selected is wrong. It should be the one, where your pip packages are installed i.e. virtual environment.

I had installed packages via pip in Windows. In Pycharm, they were neither detected nor any other Python interpreter was being shown (only python 3.6 is installed on my system).

enter image description here

I restarted the IDE. Now I was able to see python interpreter created in my virtual environment. Select that python interpreter and all your packages will be shown and detected. Enjoy!

enter image description here

answered Sep 18, 2017 at 17:37

NightFury's user avatar

NightFuryNightFury

13.4k6 gold badges70 silver badges120 bronze badges

0

Using dual python 2.7 and 3.4 with 2.7 as default, I’ve always used pip3 to install modules for the 3.4 interpreter, and pip to install modules for the 2.7 interpreter.

Try this:

pip3 install requests

answered Mar 25, 2016 at 13:48

insecure-IT's user avatar

insecure-ITinsecure-IT

2,0584 gold badges18 silver badges26 bronze badges

2

This is because you have not selected two options while creating your project:-
** inherit global site packages
** make available to all projects
Now you need to create a new project and don’t forget to tick these two options while selecting project interpreter.

answered Jul 19, 2019 at 6:52

Neeraj Aggarwal's user avatar

The solution is easy (PyCharm 2021.2.3 Community Edition).
I’m on Windows but the user interface should be the same.
In the project tree, open External libraries > Python interpreter > venv > pyvenv.cfg.
Then change:

include-system-site-packages = false

to:

include-system-site-packages = true

PyCharm image

answered Nov 18, 2021 at 16:42

David Lopez's user avatar

David LopezDavid Lopez

3333 silver badges13 bronze badges

Before going further, I want to point out how to configure a Python interpreter in PyCharm:
[SO]: How to install Python using the «embeddable zip file» (@CristiFati’s answer). Although the question is for Win, and has some particularities, configuring PyCharm is generic enough and should apply to any situation (with minor changes).

There are multiple possible reasons for this behavior.

1. Python instance mismatch

  • Happens when there are multiple Python instances (installed, VEnvs, Conda, custom built, …) on a machine. Users think they’re using one particular instance (with a set of properties (installed packages)), but in fact they are using another (with different properties), hence the confusion. It’s harder to figure out things when the 2 instances have the same version (and somehow similar locations)

  • Happens mostly due to environmental configuration (whichever path comes 1st in ${PATH}, aliases (on Nix), …)

  • It’s not PyCharm specific (meaning that it’s more generic, also happens outside it), but a typical PyCharm related example is different console interpreter and project interpreter, leading to confusion

  • The fix is to specify full paths (and pay attention to them) when using tools like Python, PIP, …. Check [SO]: How to install a package for a specific Python version on Windows 10? (@CristiFati’s answer) for more details

  • This is precisely the reason why this question exists. There are 2 Python versions involved:

    1. Project interpreter: /Library/Frameworks/Python.framework/Versions/3.4

    2. Interpreter having the Requests module: /opt/local/Library/Frameworks/Python.framework/Versions/3.4

    well, assuming the 2 paths are not somehow related (SymLinked), but in latest OSX versions that I had the chance to check (Catalina, Big Sur, Monterey) this doesn’t happen (by default)

When dealing with this kind of error, it always helps (most likely) displaying the following information (in a script or interpreter console):

import os
import sys


print("Executable:", sys.executable)
print("Version:", sys.version)
print("CWD:", os.getcwd())
print("UName:", getattr(os, "uname", lambda: None)())
for evn in ("PATH", "PYTHONHOME", "PYTHONPATH"):
    print("{:s}: {:}".format(evn, os.environ.get(evn)))
print("sys.path:", sys.path)

2. Python‘s module search mechanism misunderstanding

  • According to [Python.Docs]: Modules — The Module Search Path:

    When a module named spam is imported, the interpreter first searches for a built-in module with that name. These module names are listed in sys.builtin_module_names. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:

    • The directory containing the input script (or the current directory when no file is specified).

    • PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

    • The installation-dependent default (by convention including a site-packages directory, handled by the site module).

    A module might be located in the current dir, or its path might be added to ${PYTHONPATH}. That could trick users into making them believe that the module is actually installed in the current Python instance (‘s site-packages). But, when running the current Python instance from a different dir (or with different ${PYTHONPATH}) the module would be missing, yielding lots of headaches

  • A somewhat related scenario: [SO]: ModuleNotFoundError: No module named ‘cryptography.hazmat’; ‘cryptography’ is not a package (@CristiFati’s answer)

  • For a fix, check [SO]: How PyCharm imports differently than system command prompt (Windows) (@CristiFati’s answer)

3. A PyCharm bug

  • Not very likely, but it could happen. An example (not related to this question): [SO]: PyCharm 2019.2 not showing Traceback on Exception (@CristiFati’s answer)

  • To fix, follow one of the options from the above URL

4. A glitch

  • Not likely, but mentioning anyway. Due to some cause (e.g.: HW / SW failure), the system ended up in an inconsistent state, yielding all kinds of strange behaviors

  • Possible fixes:

    • Restart PyCharm

    • Restart the machine

    • Recreate the project (remove the .idea dir from the project)

    • Reset PyCharm settings: from menu select File -> Manage IDE Settings -> Restore Default Settings…. Check [JetBrains]: Configuring PyCharm settings or [JetBrains.IntelliJ-Support]: Changing IDE default directories used for config, plugins, and caches storage for more details

    • Reinstall PyCharm

    Needless to say that the last 2 options should only be attempted as a last resort, and only by experts, as they might mess up other projects and not even fix the problem

Not directly related to the question, but posting:

  • [SO]: Run / Debug a Django application’s UnitTests from the mouse right click context menu in PyCharm Community Edition? (a PyCharm related investigation from a while ago)

  • [SO]: ImportError: No module named win32com.client (@CristiFati’s answer)

answered Aug 15, 2022 at 16:07

CristiFati's user avatar

CristiFatiCristiFati

37.7k9 gold badges50 silver badges86 bronze badges

  1. If you go to pycharm project interpreter -> clicked on one of the installed packages then hover -> you will see where pycharm is installing the packages. This is where you are supposed to have your package installed.

  2. Now if you did sudo -H pip3 install <package>
    pip3 installs it to different directory which is /usr/local/lib/site-packages

since it is different directory from what pycharm knows hence your package is not showing in pycharm.

Solution: just install the package using pycharm by going to File->Settings->Project->Project Interpreter -> click on (+) and search the package you want to install and just click ok.

-> you will be prompted package successfully installed and you will see it pycharm.

Pingolin's user avatar

Pingolin

3,1016 gold badges25 silver badges39 bronze badges

answered Apr 16, 2019 at 14:43

Myralyn's user avatar

2

If any one faces the same problem that he/she installs the python packages but the PyCharm IDE doesn’t shows these packages then following the following steps:

  1. Go to the project in the left side of the PyCharm IDE then
  2. Click on the venv library then
  3. Open the pyvenv.cfg file in any editor then
  4. Change this piece of code (include-system-site-packages = flase) from false to true
  5. Then save it and close it and also close then pycharm then
  6. Open PyCharm again and your problem is solved.
    Thanks

answered Jul 24, 2022 at 8:47

BilalRasheed's user avatar

This did my head in as well, and turns out, the only thing I needed to do is RESTART Pycharm. Sometimes after you’ve installed the pip, you can’t load it into your project, even if the pip shows as installed in your Settings. Bummer.

answered Jun 24, 2020 at 11:33

Beatrix Kidco's user avatar

For Anaconda:

Start Anaconda Navigator -> Enviroments -> «Your_Enviroment» -> Update Index -> Restart IDE.

Solved it for me.

answered Aug 6, 2021 at 21:23

Andreas's user avatar

AndreasAndreas

8,6293 gold badges13 silver badges38 bronze badges

After pip installing everything I needed. I went to the interpreter and re-pointed it back to where it was at already.
My case: python3.6 in /anaconda3/bin/python using virtualenv…

Additionally, before I hit the plus «+» sign to install a new package. I had to deselect the conda icon to the right of it. Seems like it would be the opposite, but only then did it recognize the packages I had/needed via query.

answered Feb 1, 2019 at 19:42

atreyHazelHispanic's user avatar

In my case the packages were installed via setup.py + easy_install, and the they ends up in *.egg directories in site_package dir, which can be recognized by python but not pycharm.

I removed them all then reinstalled with pip install and it works after that, luckily the project I was working on came up with a requirements.txt file, so the command for it was:

pip install -r ./requirement.txt

answered Jul 8, 2019 at 10:32

Ripley's user avatar

RipleyRipley

6541 gold badge6 silver badges15 bronze badges

I just ran into this issue in a brand new install/project, but I’m using the Python plugin for IntelliJ IDEA. It’s essentially the same as PyCharm but the project settings are a little different. For me, the project was pointing to the right Python virtual environment but not even built-in modules were being recognized.

It turns out the SDK classpath was empty. I added paths for venv/lib/python3.8 and venv/lib/python3.8/site-packages and the issue was resolved. File->Project Structure and under Platform Settings, click SDKs, select your Python SDK, and make sure the class paths are there.

enter image description here

answered May 22, 2020 at 16:58

Dave Wolfe's user avatar

Dave WolfeDave Wolfe

6505 silver badges14 bronze badges

pip install --user discord

above command solves my problem, just use the «—user» flag

answered Feb 26, 2022 at 17:08

Siddy Hacks's user avatar

Siddy HacksSiddy Hacks

1,78614 silver badges14 bronze badges

I fixed my particular issue by installing directly to the interpreter. Go to settings and hit the «+» below the in-use interpreter then search for the package and install. I believe I’m having the issue in the first place because I didn’t set up with my interpreter correctly with my venv (not exactly sure, but this fixed it).

I was having issues with djangorestframework-simplejwt because it was the first package I hadn’t installed to this interpreter from previous projects before starting the current one, but should work for any other package that isn’t showing as imported. To reiterate though I think this is a workaround that doesn’t solve the setup issue causing this.

enter image description here

answered Jul 6, 2022 at 7:15

blueblob26's user avatar

—WINDOWS—
if using Pycharm GUI package installer works fine for installing packages for your virtual environment but you cannot do the same in the terminal,

this is because you did not setup virtual env in your terminal, instead, your terminal uses Power Shell which doesn’t use your virtual env

there should be (venv) before you’re command line as shown instead of (PS)

if you have (PS), this means your terminal is using Power Shell instead of cmd

to fix this, click on the down arrow and select the command prompt

select command prompt

now you will get (venv) and just type pip install #package name# and the package will be added to your virtual environment

answered Sep 17, 2022 at 20:54

GTK Rex's user avatar

On windows I had to cd into the venv folder and then cd into the scripts folder, then pip install module started to work

cd venv
cd scripts
pip install module

answered Nov 24, 2019 at 9:36

madamis confidential's user avatar

instead of running pip install in the terminal -> local use terminal -> command prompt

see below image

pycharm_command_prompt_image

1

vimuth's user avatar

vimuth

4,91330 gold badges78 silver badges115 bronze badges

answered Aug 14, 2022 at 3:34

Mukul Vyas's user avatar

In your pycharm terminal run pip/pip3 install package_name

answered Nov 17, 2020 at 17:42

Anubhav's user avatar

AnubhavAnubhav

1,96422 silver badges16 bronze badges

Не понимаю, почему pycharm не видит библиотеки при импорте, хоть их установка через консоль проходит успешно. Допустим, я устанавливаю библиотеку speech_recognition через терминал(используя pip), установка проходит успешно, но при попытке импортировать библиотеку, появляется ошибка: «ModuleNotFoundError: No module named ‘speech_recognition'». После я устанавливаю эту библиотеку через менеджер пакетов, теперь ее видно, но не хватает библиотеки pyAudio. При установке pyAudio через консоль, библиотеки также не видно, а при установке pyAudio через менеджер появляется ошибка, связанная именно с самим пакетом. И по такой же схеме со всеми библиотеками, только названия меняются, поэтому не могу с ними работать, что мне делать?


  • Вопрос задан

    более года назад

  • 9523 просмотра

  • The Problem

    • The Error
    • Process of Debugging

      • Additional Thoughts
  • Thoughts on the problem
  • Links
  • Outro

The Problem

Today I stumbled upon to a not a very straightforward issue while using IntelliJ IDEA via Python Plugin, and PyCharm. In other words IntelliJ IDEA and PyCharm not recognizing installed packages inside virtual environment.

When running the script via Run button, it blows up with an error but when running the script from the command line it runs with no errors, as it supposed to.

The Error (via Run button)

$ python wierd_error.py

Traceback (most recent call last):
  File "C:Userspath_to_file", line 943, in <module>
    import bcrypt
ModuleNotFoundError: No module named 'bcrypt'

Enter fullscreen mode

Exit fullscreen mode

  1. Python script is executing.
  2. When trying to import a package blows up with an error.

The error is clearly says:

Hey man, there’s no bcrypt module, just go and install it.

BUT (DUDE, THE MODULE IS RIGHT THERE! COME ON!) it was already installed to the virtual environment, and I’m not really sure if I did something wrong, or the program didn’t do what I expected. But at that moment I wanted to break the table in half.

Before running the script I’ve created a env folder for a project to isolate it from globally installed packages.

python -m venv env

Enter fullscreen mode

Exit fullscreen mode

Then I activate it:

$ source env/Scripts/activate

(env)

Enter fullscreen mode

Exit fullscreen mode

After that, I installed a few packages via pip install. They were installed to env folder as they should, and I confirmed it via pip list command to print out all install packages in the virtualenv.

$ pip list

Package    Version
---------- -------
bcrypt     3.2.0    <-- It's there!
pip        21.1.1
setuptools 56.0.0

Enter fullscreen mode

Exit fullscreen mode

So why on Earth does the script blows up with an error while using Run button but runs smoothly from the command line both inside IntelliJ IDEA and PyCharm?

Process of debugging

Idea 1. Tinker everything inside Project Structure settings

The following examples will be from IntelliJ IDEA but almost the same thing happening in the PyCharm.

Image description

I was trying to change project interpreter SDK/Setting, create module (inside project structure settings) for absolute no reason just to test if it helps. There’s not much I could say about this idea, but this process goes in circle for a few hours in and Googling related things at the same time.

Idea 2. Test in other IDE

After trying the same thing for a few hours I tried to test if the same behavior will be in other IDE’s such as PyCharm and VSCode. And the answer is «Yes», same behavior, in terminal runs, via Run button explodes with an error.

At that point I understand that something happening inside IDE since running from a command line everything runs as it should, so I focused on figuring out what causes error inside IDE.

Idea 3. Google «pycharm not recognizing installed packages»

At this point I was trying to formulate a problem in order to google it. The first Google results was exactly what I was looking for PyCharm doesn’t recognise installed module.

This is the answer that helped to solve the problem which said:

Pycharm is unable to recognize installed local modules, since python interpreter selected is wrong. It should be the one, where your pip packages are installed i.e. virtual environment.

The person who answer the question had the similar problem I had:

I had installed packages via pip in Windows. In Pycharm, they were neither detected nor any other Python interpreter was being shown (only python 3.6 is installed on my system).

Step 4. Change Project SDK to python.exe from virtual environment

In order to make it work I first found where python.exe inside virtual environment folder is located, and copied the full path.

Then, go to Project Structure settings (CTRL+ALT+SHIFT+S) -> SDK's -> Add new SDK -> Add Python SDK -> System interpreter -> changed existing path to the one I just copied. Done!

Path changed from this:

Image description

To this:

Image description

One thing left. We also need to change Python interpreter path inside Run Configuration to the one that was just created inside System Interpreter under Project Structure:

Image description

Changing Python interpreter path from the default one:

Image description

Additional Thoughts

I’m not creating another virtual environment (venv) that PyCharm provides because I already create it from the command line beforehand, that’s why I change path inside System Interpreter.

It can be also achieved by creating new Virtual Environment instead of creating it from command line (basically the same process as described above):

  • Set Base Interpreter to whatever Python version is running.

  • Make sure that Project SDK (Project Structure window) is set to the one from Virtual Environment (Python 3.9 (some words)).

  • Open Run Configuration -> Python Interpreter -> Use specific interpreter path is set to python.exe path from the venv folder (e.g. newly created virtual environment).

Note: When using such method, Bash commands not found for unknown for me reason.

$ which python

bash: which: command not found
()  <- tells that you're currently in virtualenv

Enter fullscreen mode

Exit fullscreen mode

But when creating env manually (python -m venv env), Bash commands are working.


Thoughts on the problem

I thought that IntelliJ IDEA, PyCharm handles such things under the hood so end user doesn’t have to think about it, just create an env, activate it via $ source env/Scripts/activate and it works.

I should skip tinkering step right away after few minutes of trying to formulate the problem correctly and googling it instead of torture myself for over an hour.

In the end, I’m happy that I’ve stumbled upon such problem because with new problems it will be much easier to understand what steps to do based on the previous experience.


Links

  • StackOverflow question
  • StackOverflow answer
  • Googling the problem

Outro

If you have anything to share, any questions, suggestions, feel free to drop a comment in the comment section or reach out via Twitter at @dimitryzub.

Yours,
Dimitry

Понравилась статья? Поделить с друзьями:
  • Pxn 9613 ошибка драйвера
  • Pxe m0f ошибка на ноутбуке
  • Python обработка ошибок keyerror
  • Pxe e61 ошибка на ноутбуке
  • Python обработка любой ошибки