the problem I ran into was not installing the package in the virtual environment, taking the jieba package as an example
enter python in the virtual environment, and then you can import the package. We thought it was packaged, but it was actually installed in the basic environment.
When
USES conda list to view the packages in the current environment, there is no jieba package.
conda list
forgot the screenshot,,,,
p>
so you need to install jieba using the PIP of the virtual environment.
after confirming wrapping in a virtual environment, switching to a python environment cannot be done by simply typing python commands. Instead, use virtual environment Python, just like the previous PIP.
for example, you now have two files, test.py and test.sh.
test.py
import torch
print(torch.__version__)
test.sh
python test.py
you can see that the PIP version printed in the virtual environment is different from the one printed in the bash script.
so while I installed jieba in the pytorch1.4 environment, the command I used directly was not python in pytorch1.4, but python in the base environment.
summary:
- whether the package to the environment
- used the python interpreter is not the package environment interpreter
there are a lot of ways to do it online, so this is a supplement to what’s possible.
Read More:
- Pip Installation Warning: can’t install the package because of EnvironmentError
- [Solved] From pip._internal import cmdoptions ImportError: cannot import name SourceDistribution
- Import win32API; importerror: DLL load failed: the specified program was not found
- [Solved] import pyzed No Error, but import pyzed.sl report an Error (zed-pythonAPI Installing)
- Keras import package error: importerror: cannot import name ‘get_ config‘
- [Solved] Pycharm Use pip to install package error: no such option –build-dir
- How to Solve PIP3 error After upgrading pip3 install –upgrade pip
- [Solved] UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring it
- [Solved] pip install Error: There was a problem confirming the ssl certificate…
- Raspberry pie import opencv error: ImportError: numpy.core.multiarray failed to import
- [Solved] OpenCV Import Error: ImportError: numpy.core.multiarray failed to import
- [Solved] Python Relative Reference Error: ImportError: attempted relative import with no known parent package
- Import * has a red wavy line, but the operation does not report an error
- Failed to Create New Environment Error: Collecting package metadata (current_repodata.json): failed.
- Copy the python3 installation package to Linux and run it. Error while loading shared libraries: libpython3.6. M.so. 1.0
- [Solved] Failed to install PIP for MacOS, prompt: syntax error: invalid syntax
- [Solved] D2lzh_Pytorch Import error: importerror: DLL load failed while importing
- [Solved] Pyinstaller package opencv error: ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.
- Python ImportError: numpy.core.multiarray failed to import
- Python Import Error: SystemError: Parent module ‘‘ not loaded, cannot perform relative import