Error installing packages to conda environment within Pycharm 2019.1
Hello,
TypeError: LoadLibrary() argument 1 must be str, not None
I receive the above error code anytime I try to install a package within PyCharm to my conda environment. Can someone please shed some light on this . I am using Anaconda 3.7.3. This error does not occur outside of PyCharm.
The Command output is:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1043, in __call__
return func(*args, **kwargs)
File "C:\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "C:\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 80, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "C:\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 8, in <module>
from .install import install
File "C:\Anaconda3\lib\site-packages\conda\cli\install.py", line 19, in <module>
from ..core.index import calculate_channel_urls, get_index
File "C:\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "C:\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "C:\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "C:\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
from . import ffi
File "C:\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\Anaconda3\lib\site-packages\conda\cli\main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "C:\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "C:\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "C:\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 7, in <module>
from .tarball import CondaTarBZ2 as _CondaTarBZ2
File "C:\Anaconda3\lib\site-packages\conda_package_handling\tarball.py", line 7, in <module>
import libarchive
File "C:\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "C:\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
from . import ffi
File "C:\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
请先登录再写评论。
Does the error happen when you try to install any package? Do I understand correctly that using `conda install` from outside of PyCharm works? Try opening PyCharm's terminal and do `conda install` from there.
I have same problem with PyCharm (2019.1.3) and Conda (4.6.14). But was finding magic and strange recipe:
1. Install latest Miniconda to any dir.
2. Install latest PyCharm to default dir.
DO NOT UPDATE CONDA with default Anaconda Prompt and Anaconda Power Prompt (in Windows Start Menu)
DO NOT APPEND ANY PACKAGE with default Anaconda Prompt and Anaconda Power Prompt (in Windows Start Menu)
If you do this, all packages (PyCharm->Settings->Project->Interpreter) will disappeared.
If you want to append any package, do it throw PyCharm:
Settings -> Project -> Interpreter -> + -> choose package and press install
May be install dirs do not connect with this problem. I was doing not experimenting.
But if I try to update conda or append packages (with Anaconda Prompt in Win Start Menu). this bug appead.
Also, interesting fact. Conda couldn't activate env, that create in PyCharm
Please try the following:
1. Open terminal in PyCharm and execute `conda list` and `which python`
2. Execute the same commands in Anaconda prompt
Provide outputs for comparison.
PyCharm terminal:
Microsoft Windows [Version 10.0.17763.557]
(c) Корпорация Майкрософт (Microsoft Corporation), 2018. Все права защищены.
(TestProject) E:\PythonProjects\TestProject>conda list
# packages in environment at D:\Python\Miniconda3\envs\TestProject:
#
# Name Version Build Channel
ca-certificates 2019.5.15 0
certifi 2019.6.16 py37_0
openssl 1.1.1c he774522_1
pip 19.1.1 py37_0
python 3.7.3 h8c8aaf0_1
setuptools 41.0.1 py37_0
sqlite 3.28.0 he774522_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_4
wheel 0.33.4 py37_0
wincertstore 0.2 py37_0
(TestProject) E:\PythonProjects\TestProject>\which python
"\which" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.
-------------------------------------------------------------------------------------------
Anaconda Powershell Prompt:
(base) PS>conda list
# packages in environment at D:\Python\Miniconda3:
#
# Name Version Build Channel
asn1crypto 0.24.0 py37_0
ca-certificates 2019.1.23 0
certifi 2019.3.9 py37_0
cffi 1.12.2 py37h7a1dbc1_1
chardet 3.0.4 py37_1
conda 4.6.14 py37_0
console_shortcut 0.1.1 3
cryptography 2.6.1 py37h7a1dbc1_0
idna 2.8 py37_0
menuinst 1.4.16 py37he774522_0
openssl 1.1.1b he774522_1
pip 19.0.3 py37_0
powershell_shortcut 0.0.1 2
pycosat 0.6.3 py37hfa6e2cd_0
pycparser 2.19 py37_0
pyopenssl 19.0.0 py37_0
pysocks 1.6.8 py37_0
python 3.7.3 h8c8aaf0_0
pywin32 223 py37hfa6e2cd_1
requests 2.21.0 py37_0
ruamel_yaml 0.15.46 py37hfa6e2cd_0
setuptools 41.0.0 py37_0
six 1.12.0 py37_0
sqlite 3.27.2 he774522_0
urllib3 1.24.1 py37_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_0
wheel 0.33.1 py37_0
win_inet_pton 1.1.0 py37_0
wincertstore 0.2 py37_0
yaml 0.1.7 hc54c509_2
(base) PS>which python
which : Имя "which" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте прав
ильность написания имени, а также наличие и правильность пути, после чего повторите попытку.
строка:1 знак:1
+ which python
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (which:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-------------------------------------------------------------------------------------------
if I try to activate TestProject env via Anaconda Powershell Prompt:
(base) PS>conda activate TestProject
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "D:\Python\Miniconda3\lib\site-packages\conda\cli\main.py", line 138, in main
return activator_main()
File "D:\Python\Miniconda3\lib\site-packages\conda\activate.py", line 955, in main
print(activator.execute(), end='')
File "D:\Python\Miniconda3\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2560' in position 855: character maps to <undefined>
In the end of my previous post, I wrote, that couldn't activate env TestProject:
(base) PS>conda activate TestProject
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "D:\Python\Miniconda3\lib\site-packages\conda\cli\main.py", line 138, in main
return activator_main()
File "D:\Python\Miniconda3\lib\site-packages\conda\activate.py", line 955, in main
print(activator.execute(), end='')
File "D:\Python\Miniconda3\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2560' in position 855: character maps to <undefined>
Update. Add full content this error report:
`$ D:\Python\Miniconda3\Scripts\conda-script.py shell.powershell activate TestProject`
environment variables:
CIO_TEST=<not set>
CONDA_DEFAULT_ENV=base
CONDA_EXE=D:\Python\Miniconda3\Scripts\conda.exe
CONDA_PREFIX=D:\Python\Miniconda3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=D:\Python\Miniconda3\python.exe
CONDA_ROOT=D:\Python\Miniconda3
CONDA_SHLVL=1
HOMEPATH=\Users\Михаил
PATH=D:\Python\Miniconda3;D:\Python\Miniconda3\Library\mingw-w64\bin;D:\Pyt
hon\Miniconda3\Library\usr\bin;D:\Python\Miniconda3\Library\bin;D:\Pyt
hon\Miniconda3\Scripts;D:\Python\Miniconda3\bin;D:\Python\Miniconda3;D
:\Python\Miniconda3\Library\mingw-w64\bin;D:\Python\Miniconda3\Library
\usr\bin;D:\Python\Miniconda3\Library\bin;D:\Python\Miniconda3\Scripts
;D:\Python\Miniconda3\bin;D:\Python\Miniconda3\condabin;D:\Python\Pyth
on37\Scripts;D:\Python\Python37;C:\Windows\system32;C:\Windows;C:\Wind
ows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Window
s\System32\OpenSSH;C:\Program Files (x86)\NVIDIA
Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA Nv
DLISR;D:\Python\Python37\Scripts;D:\Python\Python37;C:\Users\╠шїршы\Ap
pData\Local\Microsoft\WindowsApps;.
PSMODULEPATH=E:\Users\Михаил\Documents\WindowsPowerShell\Modules;C:\Program Files\W
indowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : base
active env location : D:\Python\Miniconda3
shell level : 1
user config file : C:\Users\Михаил\.condarc
populated config files :
conda version : 4.6.14
conda-build version : not installed
python version : 3.7.3.final.0
base environment : D:\Python\Miniconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : D:\Python\Miniconda3\pkgs
C:\Users\Михаил\.conda\pkgs
C:\Users\8FEE~1\AppData\Local\conda\conda\pkgs
envs directories : D:\Python\Miniconda3\envs
C:\Users\Михаил\.conda\envs
C:\Users\8FEE~1\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Windows/10 Windows/10.0.17763
administrator : False
netrc file : None
offline mode : False
---------------------------
And in Anaconda PS:
(base) PS>where python
(base) PS>
--------------------------
Thats all.
In PyCharm Terminal:
(TestProject) E:\PythonProjects\TestProject>where python
D:\Python\Miniconda3\envs\TestProject\python.exe
(TestProject) E:\PythonProjects\TestProject>
---------------------
Thats all...
By the way, I can activate base env in PyCharm:
(TestProject) E:\PythonProjects\TestProject>activate base
(TestProject) E:\PythonProjects\TestProject>conda.bat activate base
(base) E:\PythonProjects\TestProject>activate TestProject
(TestProject) E:\PythonProjects\TestProject>
The point is to try installing the package under TestProject environment from your system terminal, because you've mentioned in your first post:
>This error does not occur outside of PyCharm.
But you were probably trying to install into "Base" environment, not "TestProject".
>In the end of my previous post, I wrote, that couldn't activate env TestProject:
This is Anaconda issue, unfortunately I can't help with this. You better ask on Anaconda forums.
Next experiment. I create new user in windows named "GreMal" - english chars. And install under him Miniconda and PyCharm.
And, in Anaconda PS I can activate both TestProject env and base env. )) In the PyCharm terminal, I can this too. If I am install python packages in Anaconda PS, I see this in PyCharm terminal:
PyCharm terminal:
(TestProject0) E:\PythonProjects\TestProject>conda activate TestProject
(TestProject) E:\PythonProjects\TestProject>conda list
# packages in environment at D:\Python\Miniconda3\envs\TestProject:
#
# Name Version Build Channel
blas 1.0 mkl
ca-certificates 2019.5.15 0
certifi 2019.6.16 py37_0
cffi 1.12.3 py37h7a1dbc1_0
cudatoolkit 10.0.130 0
icc_rt 2019.0.0 h0cc432a_1
intel-openmp 2019.4 245
mkl 2019.4 245
mkl_fft 1.0.12 py37h14836fe_0
mkl_random 1.0.2 py37h343c172_0
ninja 1.9.0 py37h74a9793_0
numpy 1.16.4 py37h19fb1c0_0
numpy-base 1.16.4 py37hc3f5095_0
openssl 1.1.1c he774522_1
pip 19.1.1 py37_0
pycparser 2.19 py37_0
python 3.7.3 h8c8aaf0_1
pytorch 1.1.0 py3.7_cuda100_cudnn7_1 pytorch
setuptools 41.0.1 py37_0
sqlite 3.28.0 he774522_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_4
wheel 0.33.4 py37_0
wincertstore 0.2 py37_0
(TestProject) E:\PythonProjects\TestProject>where python
D:\Python\Miniconda3\envs\TestProject\python.exe
(TestProject) E:\PythonProjects\TestProject>
----------------------------------------------------------------
Anaconda PS:
(TestProject) PS C:\Users\GreMal> conda list
# packages in environment at D:\Python\Miniconda3\envs\TestProject:
#
# Name Version Build Channel
blas 1.0 mkl
ca-certificates 2019.5.15 0
certifi 2019.6.16 py37_0
cffi 1.12.3 py37h7a1dbc1_0
cudatoolkit 10.0.130 0
icc_rt 2019.0.0 h0cc432a_1
intel-openmp 2019.4 245
mkl 2019.4 245
mkl_fft 1.0.12 py37h14836fe_0
mkl_random 1.0.2 py37h343c172_0
ninja 1.9.0 py37h74a9793_0
numpy 1.16.4 py37h19fb1c0_0
numpy-base 1.16.4 py37hc3f5095_0
openssl 1.1.1c he774522_1
pip 19.1.1 py37_0
pycparser 2.19 py37_0
python 3.7.3 h8c8aaf0_1
pytorch 1.1.0 py3.7_cuda100_cudnn7_1 pytorch
setuptools 41.0.1 py37_0
sqlite 3.28.0 he774522_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_4
wheel 0.33.4 py37_0
wincertstore 0.2 py37_0
(TestProject) PS C:\Users\GreMal> where python
(TestProject) PS C:\Users\GreMal>
---
But see screenshots, please:
Ok, now it looks as something is wrong. Please upload PyCharm logs to our FTP and let me know the file name: https://uploads.services.jetbrains.com/
You can locate logs according to https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files
Ok, I did it:
idea_02.07.19.log (491 kb)
Sorry, can't find the file on our FTP, are you sure it's uploaded?
How did you create "TestProject" environment in your last test? From PyCharm, or Anaconda prompt? What happens if you create a new conda environment in PyCharm?
PyCharm seems to use the conda.exe. But it is supposed to use conda.bat on windows, because this is setting up environment correctly:
https://github.com/conda/conda/issues/8836
@Tim
PyCharm has it's own code to setup the environment, and overwhelmingly large portion of our user base (including myself), use Conda just fine when providing conda.exe as an executable when creating new virtual environments.
This is not to say you're wrong, and maybe this solution will indeed help, but we need more data, tests, and a way to reproduce to identify the root cause.
@Andrey
Just to chime in, I have this exact issue. I created a brand new Conda environment via PyCharm new Project which setup the environment in the correct directory, C:/Python/Anaconda/envs/CondaPyCharm. Indexing looks like it worked as well.
However, the Package list is stuck on "loading" permanently when the "Use Conda Package Manager" icon is checked. Any attempts to add *any* package using the "+" sign results in
TypeError: LoadLibrary() argument 1 must be str, not None.
I can use the built-in Terminal which properly activates the respective Conda environment, in this case, "CondaPyCharm" and type "conda install <some_package_name>" with no issues. The package gets installed and does function correctly inside PyCharm, but the Package List in Settings is still stuck to "Loading".
EDIT: You can edit the __init__.py for ctypes and fix it by forcing a cast to Str but then you can "Specified Module could not be found" in Pycharm log file. However, the exact command that Pycharm is attempting to use:
conda.exe list -p C:/Python/Anaconda3/envs/CondaPyCharm -e
This will successfully work in a standard Anaconda Prompt, but not in the Pycharm Terminal Console and I believe it has to do with how Anaconda Prompt sets up the Paths / Environment. Regardless, I think Pycharm's terminal console for an Anaconda Interpreter based project should really be duplicating the environment that the Anaconda Prompt sets up.
Same issue here, @mrwizard's description is spot-on. A fresh install of Anaconda where I had it add Anaconda to the global path so it would work in Windows command line seems to have solved the problem.
Put another way: this error only seems to affect me if I deselect the 'add Anaconda to path' option during installation.
Hey Mr. Wizard, can you guide me in installing the Anaconda and PyCharm software, what should be their directory. I am having the same issue as yours.
Everyone affected by this issue, please try this: https://youtrack.jetbrains.com/issue/PY-37293#focus=streamItem-27-3638791.0-0